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


Python logging_ops.print_v2函数代码示例

本文整理汇总了Python中tensorflow.python.ops.logging_ops.print_v2函数的典型用法代码示例。如果您正苦于以下问题:Python print_v2函数的具体用法?Python print_v2怎么用?Python print_v2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_v2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testPrintOneTensorEagerOnOpCreate

 def testPrintOneTensorEagerOnOpCreate(self):
   with self.cached_session():
     with context.eager_mode():
       tensor = math_ops.range(10)
       expected = "[0 1 2 ... 7 8 9]"
       with self.captureWritesToStream(sys.stderr) as printed:
         logging_ops.print_v2(tensor)
       self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例2: testInvalidOutputStreamRaisesError

 def testInvalidOutputStreamRaisesError(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.assertRaises(ValueError):
       print_op = logging_ops.print_v2(
           tensor, output_stream="unknown")
       self.evaluate(print_op)
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:7,代码来源:logging_ops_test.py

示例3: testPrintNoTensors

 def testPrintNoTensors(self):
   with self.cached_session():
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(23, [23, 5], {"6": 12})
       self.evaluate(print_op)
     expected = "23 [23, 5] {'6': 12}"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:7,代码来源:logging_ops_test.py

示例4: testPrintStringScalar

 def testPrintStringScalar(self):
   with self.cached_session():
     tensor = ops.convert_to_tensor("scalar")
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(tensor)
       self.evaluate(print_op)
     expected = "scalar"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例5: testPrintTwoTensors

 def testPrintTwoTensors(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(tensor, tensor * 10)
       self.evaluate(print_op)
     expected = "[0 1 2 ... 7 8 9] [0 10 20 ... 70 80 90]"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例6: testPrintPlaceholderGeneration

 def testPrintPlaceholderGeneration(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2("{}6", {"{}": tensor * 10})
       self.evaluate(print_op)
     expected = "{}6 {'{}': [0 10 20 ... 70 80 90]}"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例7: testPrintStringScalarDifferentEnd

 def testPrintStringScalarDifferentEnd(self):
   with self.cached_session():
     tensor = ops.convert_to_tensor("scalar")
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(tensor, end="<customend>")
       self.evaluate(print_op)
     expected = "scalar<customend>"
     self.assertIn(expected, printed.contents())
开发者ID:aritratony,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例8: testPrintTwoTensorsDifferentSep

 def testPrintTwoTensorsDifferentSep(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(tensor, tensor * 10, sep="<separator>")
       self.evaluate(print_op)
     expected = "[0 1 2 ... 7 8 9]<separator>[0 10 20 ... 70 80 90]"
     self.assertIn(expected + "\n", printed.contents())
开发者ID:aritratony,项目名称:tensorflow,代码行数:8,代码来源:logging_ops_test.py

示例9: testPrintOneTensorStdout

 def testPrintOneTensorStdout(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.captureWritesToStream(sys.stdout) as printed:
       print_op = logging_ops.print_v2(
           tensor, output_stream=sys.stdout)
       self.evaluate(print_op)
     expected = "[0 1 2 ... 7 8 9]"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:9,代码来源:logging_ops_test.py

示例10: testPrintOneStringTensor

  def testPrintOneStringTensor(self):
    with self.cached_session():
      tensor = ops.convert_to_tensor([char for char in string.ascii_lowercase])
      with self.captureWritesToStream(sys.stderr) as printed:
        print_op = logging_ops.print_v2(tensor)
        self.evaluate(print_op)

      expected = "[\"a\" \"b\" \"c\" ... \"x\" \"y\" \"z\"]"
      self.assertIn((expected + "\n"), printed.contents())
开发者ID:aritratony,项目名称:tensorflow,代码行数:9,代码来源:logging_ops_test.py

示例11: testPrintOneVariable

 def testPrintOneVariable(self):
   with self.cached_session():
     var = variables.Variable(math_ops.range(10))
     if not context.executing_eagerly():
       variables.global_variables_initializer().run()
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(var)
       self.evaluate(print_op)
     expected = "[0 1 2 ... 7 8 9]"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:10,代码来源:logging_ops_test.py

示例12: testNoDuplicateFormatOpGraphModeAfterExplicitFormat

 def testNoDuplicateFormatOpGraphModeAfterExplicitFormat(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     formatted_string = string_ops.string_format("{}", tensor)
     print_op = logging_ops.print_v2(formatted_string)
     self.evaluate(print_op)
     graph_ops = ops.get_default_graph().get_operations()
     format_ops = [op for op in graph_ops if op.type == "StringFormat"]
     # Should be only 1 format_op for graph mode.
     self.assertEqual(len(format_ops), 1)
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:10,代码来源:logging_ops_test.py

示例13: testPrintOneTensorLogError

 def testPrintOneTensorLogError(self):
   with self.cached_session():
     tensor = math_ops.range(10)
     with self.captureWritesToStream(sys.stderr) as printed:
       print_op = logging_ops.print_v2(
           tensor, output_stream=tf_logging.error)
       self.evaluate(print_op)
     self.assertTrue("E" in printed.contents())
     expected = "[0 1 2 ... 7 8 9]"
     self.assertTrue(expected in printed.contents())
开发者ID:JonathanRaiman,项目名称:tensorflow,代码行数:10,代码来源:logging_ops_logging_level_test.py

示例14: testPrintTensorsToFile

 def testPrintTensorsToFile(self):
   tmpfile_name = tempfile.mktemp(".printv2_test")
   tensor_0 = math_ops.range(0, 10)
   print_op_0 = logging_ops.print_v2(tensor_0,
                                     output_stream="file://"+tmpfile_name)
   self.evaluate(print_op_0)
   tensor_1 = math_ops.range(11, 20)
   print_op_1 = logging_ops.print_v2(tensor_1,
                                     output_stream="file://"+tmpfile_name)
   self.evaluate(print_op_1)
   try:
     f = open(tmpfile_name, "r")
     line_0 = f.readline()
     expected_0 = "[0 1 2 ... 7 8 9]"
     self.assertTrue(expected_0 in line_0)
     line_1 = f.readline()
     expected_1 = "[11 12 13 ... 17 18 19]"
     self.assertTrue(expected_1 in line_1)
     f.close()
     os.remove(tmpfile_name)
   except IOError as e:
     self.fail(e)
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:22,代码来源:logging_ops_test.py

示例15: testPrintTwoVariablesInStructWithAssignAdd

 def testPrintTwoVariablesInStructWithAssignAdd(self):
   with self.cached_session():
     var_one = variables.Variable(2.14)
     plus_one = var_one.assign_add(1.0)
     var_two = variables.Variable(math_ops.range(10))
     if not context.executing_eagerly():
       variables.global_variables_initializer().run()
     with self.captureWritesToStream(sys.stderr) as printed:
       self.evaluate(plus_one)
       print_op = logging_ops.print_v2(var_one, {"second": var_two})
       self.evaluate(print_op)
     expected = "3.14 {'second': [0 1 2 ... 7 8 9]}"
     self.assertTrue((expected + "\n") in printed.contents())
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:13,代码来源:logging_ops_test.py


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