当前位置: 首页>>代码示例>>Python>>正文


Python test_util.TensorFlowTestCase方法代码示例

本文整理汇总了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))) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:16,代码来源:analyzer_cli_test.py

示例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) 
开发者ID:tensorflow,项目名称:text,代码行数:9,代码来源:ragged_test_util.py

示例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) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:56,代码来源:analyzer_cli_test.py


注:本文中的tensorflow.python.framework.test_util.TensorFlowTestCase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。