当前位置: 首页>>代码示例>>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;未经允许,请勿转载。