當前位置: 首頁>>代碼示例>>Python>>正文


Python exporter.regression_signature方法代碼示例

本文整理匯總了Python中tensorflow.contrib.session_bundle.exporter.regression_signature方法的典型用法代碼示例。如果您正苦於以下問題:Python exporter.regression_signature方法的具體用法?Python exporter.regression_signature怎麽用?Python exporter.regression_signature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.session_bundle.exporter的用法示例。


在下文中一共展示了exporter.regression_signature方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: regression_signature_fn

# 需要導入模塊: from tensorflow.contrib.session_bundle import exporter [as 別名]
# 或者: from tensorflow.contrib.session_bundle.exporter import regression_signature [as 別名]
def regression_signature_fn(examples, unused_features, predictions):
  """Creates regression signature from given examples and predictions.

  Args:
    examples: `Tensor`.
    unused_features: `dict` of `Tensor`s.
    predictions: `Tensor`.

  Returns:
    Tuple of default regression signature and empty named signatures.

  Raises:
    ValueError: If examples is `None`.
  """
  if examples is None:
    raise ValueError('examples cannot be None when using this signature fn.')

  default_signature = exporter.regression_signature(
      input_tensor=examples, output_tensor=predictions)
  return default_signature, {} 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:export.py

示例2: Export

# 需要導入模塊: from tensorflow.contrib.session_bundle import exporter [as 別名]
# 或者: from tensorflow.contrib.session_bundle.exporter import regression_signature [as 別名]
def Export():
  export_path = "/tmp/half_plus_two"
  with tf.Session() as sess:
    # Make model parameters a&b variables instead of constants to
    # exercise the variable reloading mechanisms.
    a = tf.Variable(0.5)
    b = tf.Variable(2.0)

    # Calculate, y = a*x + b
    # here we use a placeholder 'x' which is fed at inference time.
    x = tf.placeholder(tf.float32)
    y = tf.add(tf.multiply(a, x), b)

    # Run an export.
    tf.global_variables_initializer().run()
    export = exporter.Exporter(tf.train.Saver())
    export.init(named_graph_signatures={
        "inputs": exporter.generic_signature({"x": x}),
        "outputs": exporter.generic_signature({"y": y}),
        "regress": exporter.regression_signature(x, y)
    })
    export.export(export_path, tf.constant(123), sess) 
開發者ID:helmut-hoffer-von-ankershoffen,項目名稱:jetson,代碼行數:24,代碼來源:export_half_plus_two.py

示例3: _create_signature_fn

# 需要導入模塊: from tensorflow.contrib.session_bundle import exporter [as 別名]
# 或者: from tensorflow.contrib.session_bundle.exporter import regression_signature [as 別名]
def _create_signature_fn(self):
    def _regression_signature_fn(examples, unused_features, predictions):
      if isinstance(predictions, dict):
        score = predictions[prediction_key.PredictionKey.SCORES]
      else:
        score = predictions

      default_signature = exporter.regression_signature(
          input_tensor=examples, output_tensor=score)
      # TODO(zakaria): add validation
      return default_signature, {}
    return _regression_signature_fn 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:head.py

示例4: logistic_regression_signature_fn

# 需要導入模塊: from tensorflow.contrib.session_bundle import exporter [as 別名]
# 或者: from tensorflow.contrib.session_bundle.exporter import regression_signature [as 別名]
def logistic_regression_signature_fn(examples, unused_features, predictions):
  """Creates logistic regression signature from given examples and predictions.

  Args:
    examples: `Tensor`.
    unused_features: `dict` of `Tensor`s.
    predictions: `Tensor` of shape [batch_size, 2] of predicted probabilities or
      dict that contains the probabilities tensor as in
      {'probabilities', `Tensor`}.

  Returns:
    Tuple of default regression signature and named signature.

  Raises:
    ValueError: If examples is `None`.
  """
  if examples is None:
    raise ValueError('examples cannot be None when using this signature fn.')

  if isinstance(predictions, dict):
    predictions_tensor = predictions['probabilities']
  else:
    predictions_tensor = predictions
  # predictions should have shape [batch_size, 2] where first column is P(Y=0|x)
  # while second column is P(Y=1|x). We are only interested in the second
  # column for inference.
  predictions_shape = predictions_tensor.get_shape()
  predictions_rank = len(predictions_shape)
  if predictions_rank != 2:
    logging.fatal(
        'Expected predictions to have rank 2, but received predictions with '
        'rank: {} and shape: {}'.format(predictions_rank, predictions_shape))
  if predictions_shape[1] != 2:
    logging.fatal(
        'Expected predictions to have 2nd dimension: 2, but received '
        'predictions with 2nd dimension: {} and shape: {}. Did you mean to use '
        'regression_signature_fn or classification_signature_fn_with_prob '
        'instead?'.format(predictions_shape[1], predictions_shape))

  positive_predictions = predictions_tensor[:, 1]
  default_signature = exporter.regression_signature(
      input_tensor=examples, output_tensor=positive_predictions)
  return default_signature, {}


# pylint: disable=protected-access 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:48,代碼來源:export.py


注:本文中的tensorflow.contrib.session_bundle.exporter.regression_signature方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。