本文整理汇总了Python中tensorflow.contrib.learn.python.learn.estimators.tensor_signature.create_placeholders_from_signatures函数的典型用法代码示例。如果您正苦于以下问题:Python create_placeholders_from_signatures函数的具体用法?Python create_placeholders_from_signatures怎么用?Python create_placeholders_from_signatures使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_placeholders_from_signatures函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSparseTensorSignaturePlaceholders
def testSparseTensorSignaturePlaceholders(self):
tensor = tf.SparseTensor(values=[1.0, 2.0], indices=[[0, 2], [0, 3]],
shape=[5, 5])
signature = tensor_signature.create_signatures(tensor)
placeholder = tensor_signature.create_placeholders_from_signatures(
signature)
self.assertTrue(isinstance(placeholder, tf.SparseTensor))
self.assertEqual(placeholder.values.dtype, tensor.values.dtype)
示例2: testTensorSignaturePlaceholders
def testTensorSignaturePlaceholders(self):
placeholder_a = array_ops.placeholder(
name='test', shape=[None, 100], dtype=dtypes.int32)
signatures = tensor_signature.create_signatures(placeholder_a)
placeholder_out = tensor_signature.create_placeholders_from_signatures(
signatures)
self.assertEqual(placeholder_out.dtype, placeholder_a.dtype)
self.assertTrue(placeholder_out.get_shape().is_compatible_with(
placeholder_a.get_shape()))
self.assertTrue(
tensor_signature.tensors_compatible(placeholder_out, signatures))
inputs = {'a': placeholder_a}
signatures = tensor_signature.create_signatures(inputs)
placeholders_out = tensor_signature.create_placeholders_from_signatures(
signatures)
self.assertEqual(placeholders_out['a'].dtype, placeholder_a.dtype)
self.assertTrue(placeholders_out['a'].get_shape().is_compatible_with(
placeholder_a.get_shape()))
self.assertTrue(
tensor_signature.tensors_compatible(placeholders_out, signatures))
示例3: _get_predict_ops
def _get_predict_ops(self, features):
"""Method that builds model graph and returns prediction ops.
Expected to be overriden by sub-classes that require custom support.
This implementation uses `model_fn` passed as parameter to constructor to
build model.
Args:
features: `Tensor` or `dict` of `Tensor` objects.
Returns:
predictions: `Tensor` or `dict` of `Tensor` objects.
"""
targets = tensor_signature.create_placeholders_from_signatures(self._targets_info)
predictions, _, _ = self._call_model_fn(features, targets, ModeKeys.INFER)
return predictions
示例4: _get_predict_ops
def _get_predict_ops(self, features):
"""Method that builds model graph and returns prediction ops.
Expected to be overriden by sub-classes that require custom support.
This implementation uses `model_fn` passed as parameter to constructor to
build model.
Args:
features: `Tensor` or `dict` of `Tensor` objects.
Returns:
`ModelFnOps` object.
"""
self._set_infer_mode_feature_signature(features)
labels = tensor_signature.create_placeholders_from_signatures(
self._labels_info[model_fn_lib.ModeKeys.INFER])
return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.INFER)
示例5: testTensorPlaceholderNone
def testTensorPlaceholderNone(self):
self.assertEqual(
None, tensor_signature.create_placeholders_from_signatures(None))