本文整理汇总了Python中tensorflow.python.framework.test_util.TensorFlowTestCase方法的典型用法代码示例。如果您正苦于以下问题:Python test_util.TensorFlowTestCase方法的具体用法?Python test_util.TensorFlowTestCase怎么用?Python test_util.TensorFlowTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.framework.test_util
的用法示例。
在下文中一共展示了test_util.TensorFlowTestCase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_error_output
# 需要导入模块: from tensorflow.python.framework import test_util [as 别名]
# 或者: from tensorflow.python.framework.test_util import TensorFlowTestCase [as 别名]
def check_error_output(tst, out, command_prefix, args):
"""Check RichTextLines output from invalid/erroneous commands.
Args:
tst: A test_util.TensorFlowTestCase instance.
out: The RichTextLines object to be checked.
command_prefix: The command prefix of the command that caused the error.
args: The arguments (excluding prefix) of the command that caused the error.
"""
tst.assertGreater(len(out.lines), 2)
tst.assertStartsWith(out.lines[0],
"Error occurred during handling of command: %s %s" %
(command_prefix, " ".join(args)))
示例2: _eval_tensor
# 需要导入模块: from tensorflow.python.framework import test_util [as 别名]
# 或者: from tensorflow.python.framework.test_util import TensorFlowTestCase [as 别名]
def _eval_tensor(self, tensor):
if ragged_tensor.is_ragged(tensor):
return ragged_tensor_value.RaggedTensorValue(
self._eval_tensor(tensor.values),
self._eval_tensor(tensor.row_splits))
else:
return test_util.TensorFlowTestCase._eval_tensor(self, tensor)
示例3: assert_listed_tensors
# 需要导入模块: from tensorflow.python.framework import test_util [as 别名]
# 或者: from tensorflow.python.framework.test_util import TensorFlowTestCase [as 别名]
def assert_listed_tensors(tst,
out,
expected_tensor_names,
node_name_regex=None,
op_type_regex=None,
tensor_filter_name=None):
"""Check RichTextLines output for list_tensors commands.
Args:
tst: A test_util.TensorFlowTestCase instance.
out: The RichTextLines object to be checked.
expected_tensor_names: Expected tensor names in the list.
node_name_regex: Optional: node name regex filter.
op_type_regex: Optional: op type regex filter.
tensor_filter_name: Optional: name of the tensor filter.
"""
line_iter = iter(out.lines)
num_tensors = len(expected_tensor_names)
if tensor_filter_name is None:
tst.assertEqual("%d dumped tensor(s):" % num_tensors, next(line_iter))
else:
tst.assertEqual("%d dumped tensor(s) passing filter \"%s\":" %
(num_tensors, tensor_filter_name), next(line_iter))
if op_type_regex is not None:
tst.assertEqual("Op type regex filter: \"%s\"" % op_type_regex,
next(line_iter))
if node_name_regex is not None:
tst.assertEqual("Node name regex filter: \"%s\"" % node_name_regex,
next(line_iter))
tst.assertEqual("", next(line_iter))
# Verify the listed tensors and their timestamps.
tensor_timestamps = []
tensor_names = []
for line in line_iter:
rel_time = float(line.split("ms] ")[0].replace("[", ""))
tst.assertGreaterEqual(rel_time, 0.0)
tensor_timestamps.append(rel_time)
tensor_names.append(line.split("ms] ")[1])
# Verify that the tensors should be listed in ascending order of their
# timestamps.
tst.assertEqual(sorted(tensor_timestamps), tensor_timestamps)
# Verify that the tensors are all listed.
for tensor_name in expected_tensor_names:
tst.assertIn(tensor_name, tensor_names)