本文整理汇总了Python中tensorflow.contrib.learn.python.learn.estimators.tensor_signature.create_signatures函数的典型用法代码示例。如果您正苦于以下问题:Python create_signatures函数的具体用法?Python create_signatures怎么用?Python create_signatures使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_signatures函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testUnknownShape
def testUnknownShape(self):
placeholder_unk = array_ops.placeholder(
name='unk', shape=None, dtype=dtypes.string)
placeholder_a = array_ops.placeholder(
name='a', shape=[None], dtype=dtypes.string)
placeholder_b = array_ops.placeholder(
name='b', shape=[128, 2], dtype=dtypes.string)
placeholder_c = array_ops.placeholder(
name='c', shape=[128, 2], dtype=dtypes.int32)
unk_signature = tensor_signature.create_signatures(placeholder_unk)
# Tensors of same dtype match unk shape signature.
self.assertTrue(
tensor_signature.tensors_compatible(placeholder_unk, unk_signature))
self.assertTrue(
tensor_signature.tensors_compatible(placeholder_a, unk_signature))
self.assertTrue(
tensor_signature.tensors_compatible(placeholder_b, unk_signature))
self.assertFalse(
tensor_signature.tensors_compatible(placeholder_c, unk_signature))
string_signature = tensor_signature.create_signatures(placeholder_a)
int_signature = tensor_signature.create_signatures(placeholder_c)
# Unk shape Tensor matche signatures same dtype.
self.assertTrue(
tensor_signature.tensors_compatible(placeholder_unk, string_signature))
self.assertFalse(
tensor_signature.tensors_compatible(placeholder_unk, int_signature))
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:27,代码来源:tensor_signature_test.py
示例2: testTensorSignatureCompatible
def testTensorSignatureCompatible(self):
placeholder_a = tf.placeholder(name='test',
shape=[None, 100],
dtype=tf.int32)
placeholder_b = tf.placeholder(name='another',
shape=[256, 100],
dtype=tf.int32)
placeholder_c = tf.placeholder(name='mismatch',
shape=[256, 100],
dtype=tf.float32)
signatures = tensor_signature.create_signatures(placeholder_a)
self.assertTrue(tensor_signature.tensors_compatible(placeholder_a,
signatures))
self.assertTrue(tensor_signature.tensors_compatible(placeholder_b,
signatures))
self.assertFalse(tensor_signature.tensors_compatible(placeholder_c,
signatures))
inputs = {'a': placeholder_a}
signatures = tensor_signature.create_signatures(inputs)
self.assertTrue(tensor_signature.tensors_compatible(inputs, signatures))
self.assertFalse(tensor_signature.tensors_compatible(placeholder_a,
signatures))
self.assertFalse(tensor_signature.tensors_compatible(placeholder_b,
signatures))
self.assertFalse(tensor_signature.tensors_compatible(
{'b': placeholder_b}, signatures))
self.assertTrue(tensor_signature.tensors_compatible(
{'a': placeholder_b,
'c': placeholder_c}, signatures))
self.assertFalse(tensor_signature.tensors_compatible(
{'a': placeholder_c}, signatures))
开发者ID:01-,项目名称:tensorflow,代码行数:32,代码来源:tensor_signature_test.py
示例3: testTensorSignatureExampleParserSingle
def testTensorSignatureExampleParserSingle(self):
examples = tf.placeholder(name='example', shape=[None], dtype=tf.string)
placeholder_a = tf.placeholder(name='test',
shape=[None, 100],
dtype=tf.int32)
signatures = tensor_signature.create_signatures(placeholder_a)
result = tensor_signature.create_example_parser_from_signatures(
signatures, examples)
self.assertTrue(tensor_signature.tensors_compatible(result, signatures))
new_signatures = tensor_signature.create_signatures(result)
self.assertTrue(new_signatures.is_compatible_with(signatures))
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:11,代码来源:tensor_signature_test.py
示例4: testTensorSignatureExampleParserDict
def testTensorSignatureExampleParserDict(self):
examples = array_ops.placeholder(
name='example', shape=[None], dtype=dtypes.string)
placeholder_a = array_ops.placeholder(
name='test', shape=[None, 100], dtype=dtypes.int32)
placeholder_b = array_ops.placeholder(
name='bb', shape=[None, 100], dtype=dtypes.float64)
inputs = {'a': placeholder_a, 'b': placeholder_b}
signatures = tensor_signature.create_signatures(inputs)
result = tensor_signature.create_example_parser_from_signatures(signatures,
examples)
self.assertTrue(tensor_signature.tensors_compatible(result, signatures))
new_signatures = tensor_signature.create_signatures(result)
self.assertTrue(new_signatures['a'].is_compatible_with(signatures['a']))
self.assertTrue(new_signatures['b'].is_compatible_with(signatures['b']))
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:15,代码来源:tensor_signature_test.py
示例5: _check_inputs
def _check_inputs(self, features, targets):
if self._features_info is not None:
if not tensor_signature.tensors_compatible(features, self._features_info):
raise ValueError('Features are incompatible with given information. '
'Given features: %s, required signatures: %s.' %
(str(features), str(self._features_info)))
else:
self._features_info = tensor_signature.create_signatures(features)
if self._targets_info is not None:
if not tensor_signature.tensors_compatible(targets, self._targets_info):
raise ValueError('Targets are incompatible with given information. '
'Given targets: %s, required signatures: %s.' %
(str(targets), str(self._targets_info)))
else:
self._targets_info = tensor_signature.create_signatures(targets)
开发者ID:Absarvar,项目名称:tensorflow,代码行数:15,代码来源:estimator.py
示例6: 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)
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:8,代码来源:tensor_signature_test.py
示例7: 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))
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:21,代码来源:tensor_signature_test.py
示例8: _check_inputs
def _check_inputs(self, features, labels):
if self._features_info is not None:
logging.debug('Given features: %s, required signatures: %s.',
str(features), str(self._features_info))
if not tensor_signature.tensors_compatible(features, self._features_info):
raise ValueError('Features are incompatible with given information. '
'Given features: %s, required signatures: %s.' %
(str(features), str(self._features_info)))
else:
self._features_info = tensor_signature.create_signatures(features)
logging.debug('Setting feature info to %s.', str(self._features_info))
if labels is not None:
if self._labels_info is not None:
logging.debug('Given labels: %s, required signatures: %s.',
str(labels), str(self._labels_info))
if not tensor_signature.tensors_compatible(labels, self._labels_info):
raise ValueError('Labels are incompatible with given information. '
'Given labels: %s, required signatures: %s.' %
(str(labels), str(self._labels_info)))
else:
self._labels_info = tensor_signature.create_signatures(labels)
logging.debug('Setting labels info to %s', str(self._labels_info))
开发者ID:DavidNemeskey,项目名称:tensorflow,代码行数:22,代码来源:estimator.py
示例9: _check_inputs
def _check_inputs(self, features, targets):
if self._features_info is not None:
logging.warning("Given features: %s, required signatures: %s.", str(features), str(self._features_info))
if not tensor_signature.tensors_compatible(features, self._features_info):
raise ValueError(
"Features are incompatible with given information. "
"Given features: %s, required signatures: %s." % (str(features), str(self._features_info))
)
else:
self._features_info = tensor_signature.create_signatures(features)
logging.warning("Setting feature info to %s", str(self._features_info))
if targets is not None:
if self._targets_info is not None:
logging.warning("Given targets: %s, required signatures: %s.", str(targets), str(self._targets_info))
if not tensor_signature.tensors_compatible(targets, self._targets_info):
raise ValueError(
"Targets are incompatible with given information. "
"Given targets: %s, required signatures: %s." % (str(targets), str(self._targets_info))
)
else:
self._targets_info = tensor_signature.create_signatures(targets)
logging.warning("Setting targets info to %s", str(self._targets_info))
开发者ID:MrRabbit0o0,项目名称:tensorflow,代码行数:22,代码来源:estimator.py
示例10: testSparseTensorCompatible
def testSparseTensorCompatible(self):
t = tf.SparseTensor(
indices=[[0, 0], [1, 2]], values=[1, 2], dense_shape=[3, 4])
signatures = tensor_signature.create_signatures(t)
self.assertTrue(tensor_signature.tensors_compatible(t, signatures))
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:5,代码来源:tensor_signature_test.py
示例11: testTensorSignatureNone
def testTensorSignatureNone(self):
self.assertEqual(None, tensor_signature.create_signatures(None))
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:2,代码来源:tensor_signature_test.py
注:本文中的tensorflow.contrib.learn.python.learn.estimators.tensor_signature.create_signatures函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论