本文整理匯總了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)