• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test.test_src_dir_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

  def setUp(self):
    ops.reset_default_graph()
    dim = 1
    num = 3
    with ops.name_scope('some_scope'):
      # Basically from 0 to dim*num-1.
      flat_data = math_ops.linspace(0.0, dim * num - 1, dim * num)
      bias = variables.Variable(
          array_ops.reshape(flat_data, (num, dim)), name='bias')
    save = saver.Saver([bias])
    with self.test_session() as sess:
      variables.global_variables_initializer().run()
      self.bundle_file = os.path.join(test.get_temp_dir(), 'bias_checkpoint')
      save.save(sess, self.bundle_file)

    self.new_class_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'keyword_new.txt')
    self.old_class_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'keyword.txt')
    self.init_val = 42

    def _init_val_initializer(shape, dtype=None, partition_info=None):
      del dtype, partition_info  # Unused by this unit-testing initializer.
      return array_ops.tile(
          constant_op.constant([[self.init_val]], dtype=dtypes.float32), shape)

    self.initializer = _init_val_initializer
开发者ID:1000sprites,项目名称:tensorflow,代码行数:27,代码来源:checkpoint_ops_test.py


示例2: testMaybeSessionBundleDir

 def testMaybeSessionBundleDir(self):
   base_path = test.test_src_dir_path(SESSION_BUNDLE_PATH)
   self.assertTrue(session_bundle.maybe_session_bundle_dir(base_path))
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   self.assertFalse(session_bundle.maybe_session_bundle_dir(base_path))
   base_path = "complete_garbage"
   self.assertFalse(session_bundle.maybe_session_bundle_dir(base_path))
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:7,代码来源:session_bundle_test.py


示例3: testMaybeSavedModelDir

 def testMaybeSavedModelDir(self):
   base_path = test.test_src_dir_path("/python/saved_model")
   self.assertFalse(loader.maybe_saved_model_directory(base_path))
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   self.assertTrue(loader.maybe_saved_model_directory(base_path))
   base_path = "complete_garbage"
   self.assertFalse(loader.maybe_saved_model_directory(base_path))
开发者ID:KiaraStarlab,项目名称:tensorflow,代码行数:7,代码来源:saved_model_test.py


示例4: testRunCommandWithDebuggerEnabled

  def testRunCommandWithDebuggerEnabled(self):
    self.parser = saved_model_cli.create_parser()
    base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
    x = np.array([[1], [2]])
    x_notused = np.zeros((6, 3))
    input_path = os.path.join(test.get_temp_dir(),
                              'testRunCommandNewOutdir_inputs.npz')
    output_dir = os.path.join(test.get_temp_dir(), 'new_dir')
    if os.path.isdir(output_dir):
      shutil.rmtree(output_dir)
    np.savez(input_path, x0=x, x1=x_notused)
    args = self.parser.parse_args([
        'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
        'serving_default', '--inputs', 'x=' + input_path + '[x0]', '--outdir',
        output_dir, '--tf_debug'
    ])

    def fake_wrapper_session(sess):
      return sess

    with test.mock.patch.object(local_cli_wrapper,
                                'LocalCLIDebugWrapperSession',
                                side_effect=fake_wrapper_session,
                                autospec=True) as fake:
      saved_model_cli.run(args)
      fake.assert_called_with(test.mock.ANY)

    y_actual = np.load(os.path.join(output_dir, 'y.npy'))
    y_expected = np.array([[2.5], [3.0]])
    self.assertAllClose(y_expected, y_actual)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:30,代码来源:saved_model_cli_test.py


示例5: testEval

  def testEval(self):
    if not trt_convert.is_tensorrt_enabled():
      return
    model_dir = test.test_src_dir_path('contrib/tensorrt/test/testdata')

    accuracy_tf_native = self._Run(
        is_training=False,
        use_trt=False,
        batch_size=128,
        num_epochs=None,
        model_dir=model_dir)['accuracy']
    logging.info('accuracy_tf_native: %f', accuracy_tf_native)
    self.assertAllClose(accuracy_tf_native, 0.9662)

    if trt_convert.get_linked_tensorrt_version()[0] < 5:
      return

    accuracy_tf_trt = self._Run(
        is_training=False,
        use_trt=True,
        batch_size=128,
        num_epochs=None,
        model_dir=model_dir)['accuracy']
    logging.info('accuracy_tf_trt: %f', accuracy_tf_trt)
    self.assertAllClose(accuracy_tf_trt, 0.9677)
开发者ID:aeverall,项目名称:tensorflow,代码行数:25,代码来源:quantization_mnist_test.py


示例6: testBasic

  def testBasic(self):
    base_path = test.test_src_dir_path(SESSION_BUNDLE_PATH)
    ops.reset_default_graph()
    sess, meta_graph_def = session_bundle.load_session_bundle_from_path(
        base_path,
        target="",
        config=config_pb2.ConfigProto(device_count={"CPU": 2}))

    self.assertTrue(sess)
    asset_path = os.path.join(base_path, constants.ASSETS_DIRECTORY)
    with sess.as_default():
      path1, path2 = sess.run(["filename1:0", "filename2:0"])
      self.assertEqual(
          compat.as_bytes(os.path.join(asset_path, "hello1.txt")), path1)
      self.assertEqual(
          compat.as_bytes(os.path.join(asset_path, "hello2.txt")), path2)

      collection_def = meta_graph_def.collection_def

      signatures_any = collection_def[constants.SIGNATURES_KEY].any_list.value
      self.assertEquals(len(signatures_any), 1)

      signatures = manifest_pb2.Signatures()
      signatures_any[0].Unpack(signatures)
      self._checkRegressionSignature(signatures, sess)
      self._checkNamedSignatures(signatures, sess)
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:26,代码来源:session_bundle_test.py


示例7: testShowCommandErrorNoTagSet

 def testShowCommandErrorNoTagSet(self):
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   self.parser = saved_model_cli.create_parser()
   args = self.parser.parse_args(
       ['show', '--dir', base_path, '--tag_set', 'badtagset'])
   with self.assertRaises(RuntimeError):
     saved_model_cli.show(args)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:7,代码来源:saved_model_cli_test.py


示例8: testEval

  def testEval(self):
    if not is_tensorrt_enabled():
      return
    model_dir = test.test_src_dir_path('python/compiler/tensorrt/test/testdata')

    accuracy_tf_native = self._Run(
        is_training=False,
        use_trt=False,
        batch_size=128,
        num_epochs=None,
        model_dir=model_dir)['accuracy']
    logging.info('accuracy_tf_native: %f', accuracy_tf_native)
    self.assertAllClose(0.9662, accuracy_tf_native, rtol=3e-3, atol=3e-3)

    if get_linked_tensorrt_version()[0] < 5:
      return

    accuracy_tf_trt = self._Run(
        is_training=False,
        use_trt=True,
        batch_size=128,
        num_epochs=None,
        model_dir=model_dir)['accuracy']
    logging.info('accuracy_tf_trt: %f', accuracy_tf_trt)
    self.assertAllClose(0.9675, accuracy_tf_trt, rtol=1e-3, atol=1e-3)
开发者ID:kylin9872,项目名称:tensorflow,代码行数:25,代码来源:quantization_mnist_test.py


示例9: setUpClass

  def setUpClass(cls):
    gpu_memory_fraction_opt = (
        "--gpu_memory_fraction=%f" % cls.PER_PROC_GPU_MEMORY_FRACTION)

    worker_port = portpicker.pick_unused_port()
    cluster_spec = "worker|localhost:%d" % worker_port
    tf_logging.info("cluster_spec: %s", cluster_spec)

    server_bin = test.test_src_dir_path("python/debug/grpc_tensorflow_server")

    cls.server_target = "grpc://localhost:%d" % worker_port

    cls.server_procs = {}
    cls.server_procs["worker"] = subprocess.Popen(
        [
            server_bin,
            "--cluster_spec=%s" % cluster_spec,
            "--job_name=worker",
            "--task_id=0",
            gpu_memory_fraction_opt,
        ],
        stdout=sys.stdout,
        stderr=sys.stderr)

    # Start debug server in-process, on separate thread.
    (cls.debug_server_port, cls.debug_server_url, _, cls.debug_server_thread,
     cls.debug_server
    ) = grpc_debug_test_server.start_server_on_separate_thread(
        dump_to_filesystem=False)
    tf_logging.info("debug server url: %s", cls.debug_server_url)

    cls.session_config = config_pb2.ConfigProto(
        gpu_options=config_pb2.GPUOptions(
            per_process_gpu_memory_fraction=cls.PER_PROC_GPU_MEMORY_FRACTION))
开发者ID:perfmjs,项目名称:tensorflow,代码行数:34,代码来源:dist_session_debug_grpc_test.py


示例10: testRunCommandInputNotGivenError

 def testRunCommandInputNotGivenError(self):
   self.parser = saved_model_cli.create_parser()
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   args = self.parser.parse_args([
       'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
       'serving_default'
   ])
   with self.assertRaises(AttributeError):
     saved_model_cli.run(args)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:9,代码来源:saved_model_cli_test.py


示例11: testRunCommandInvalidInputKeyError

 def testRunCommandInvalidInputKeyError(self):
   self.parser = saved_model_cli.create_parser()
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   args = self.parser.parse_args([
       'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
       'regress_x2_to_y3', '--input_exprs', 'x2=np.ones((3,1))'
   ])
   with self.assertRaises(ValueError):
     saved_model_cli.run(args)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:9,代码来源:saved_model_cli_test.py


示例12: testBadPath

 def testBadPath(self):
   base_path = test.test_src_dir_path("/no/such/a/dir")
   ops.reset_default_graph()
   with self.assertRaises(RuntimeError) as cm:
     _, _ = session_bundle.load_session_bundle_from_path(
         base_path,
         target="local",
         config=config_pb2.ConfigProto(device_count={"CPU": 2}))
   self.assertTrue("Expected meta graph file missing" in str(cm.exception))
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:9,代码来源:session_bundle_test.py


示例13: testShowCommandTags

 def testShowCommandTags(self):
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   self.parser = saved_model_cli.create_parser()
   args = self.parser.parse_args(['show', '--dir', base_path])
   with captured_output() as (out, err):
     saved_model_cli.show(args)
   output = out.getvalue().strip()
   exp_out = 'The given SavedModel contains the following tag-sets:\nserve'
   self.assertMultiLineEqual(output, exp_out)
   self.assertEqual(err.getvalue().strip(), '')
开发者ID:DILASSS,项目名称:tensorflow,代码行数:10,代码来源:saved_model_cli_test.py


示例14: setUp

  def setUp(self):
    self.bundle_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'bundle_checkpoint')
    self.new_feature_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'bundle_checkpoint_vocab.txt')
    self.old_feature_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH),
        'bundle_checkpoint_vocab_with_oov.txt')
    self.new_class_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'keyword_new.txt')
    self.old_class_vocab_file = os.path.join(
        test.test_src_dir_path(_TESTDATA_PATH), 'keyword.txt')
    self.init_val = 42

    def _init_val_initializer(shape, dtype=None, partition_info=None):
      del dtype, partition_info  # Unused by this unit-testing initializer.
      return array_ops.tile(
          constant_op.constant([[self.init_val]], dtype=dtypes.float32), shape)

    self.initializer = _init_val_initializer
开发者ID:AutumnQYN,项目名称:tensorflow,代码行数:20,代码来源:checkpoint_ops_test.py


示例15: testConvertSignaturesToSignatureDefs

  def testConvertSignaturesToSignatureDefs(self):
    base_path = test.test_src_dir_path(SESSION_BUNDLE_PATH)
    meta_graph_filename = os.path.join(base_path,
                                       constants.META_GRAPH_DEF_FILENAME)
    metagraph_def = meta_graph.read_meta_graph_file(meta_graph_filename)
    default_signature_def, named_signature_def = (
        bundle_shim._convert_signatures_to_signature_defs(metagraph_def))
    self.assertEqual(default_signature_def.method_name,
                     signature_constants.REGRESS_METHOD_NAME)
    self.assertEqual(len(default_signature_def.inputs), 1)
    self.assertEqual(len(default_signature_def.outputs), 1)
    self.assertProtoEquals(
        default_signature_def.inputs[signature_constants.REGRESS_INPUTS],
        meta_graph_pb2.TensorInfo(name="tf_example:0"))
    self.assertProtoEquals(
        default_signature_def.outputs[signature_constants.REGRESS_OUTPUTS],
        meta_graph_pb2.TensorInfo(name="Identity:0"))
    self.assertEqual(named_signature_def.method_name,
                     signature_constants.PREDICT_METHOD_NAME)
    self.assertEqual(len(named_signature_def.inputs), 1)
    self.assertEqual(len(named_signature_def.outputs), 1)
    self.assertProtoEquals(
        named_signature_def.inputs["x"], meta_graph_pb2.TensorInfo(name="x:0"))
    self.assertProtoEquals(
        named_signature_def.outputs["y"], meta_graph_pb2.TensorInfo(name="y:0"))

    # Now try default signature only
    collection_def = metagraph_def.collection_def
    signatures_proto = manifest_pb2.Signatures()
    signatures = collection_def[constants.SIGNATURES_KEY].any_list.value[0]
    signatures.Unpack(signatures_proto)
    named_only_signatures_proto = manifest_pb2.Signatures()
    named_only_signatures_proto.CopyFrom(signatures_proto)

    default_only_signatures_proto = manifest_pb2.Signatures()
    default_only_signatures_proto.CopyFrom(signatures_proto)
    default_only_signatures_proto.named_signatures.clear()
    default_only_signatures_proto.ClearField("named_signatures")
    metagraph_def.collection_def[constants.SIGNATURES_KEY].any_list.value[
        0].Pack(default_only_signatures_proto)
    default_signature_def, named_signature_def = (
        bundle_shim._convert_signatures_to_signature_defs(metagraph_def))
    self.assertEqual(default_signature_def.method_name,
                     signature_constants.REGRESS_METHOD_NAME)
    self.assertEqual(named_signature_def, None)

    named_only_signatures_proto.ClearField("default_signature")
    metagraph_def.collection_def[constants.SIGNATURES_KEY].any_list.value[
        0].Pack(named_only_signatures_proto)
    default_signature_def, named_signature_def = (
        bundle_shim._convert_signatures_to_signature_defs(metagraph_def))
    self.assertEqual(named_signature_def.method_name,
                     signature_constants.PREDICT_METHOD_NAME)
    self.assertEqual(default_signature_def, None)
开发者ID:AliMiraftab,项目名称:tensorflow,代码行数:54,代码来源:bundle_shim_test.py


示例16: testRunCommandInputExamplesFeatureBadType

 def testRunCommandInputExamplesFeatureBadType(self):
   self.parser = saved_model_cli.create_parser()
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   output_dir = os.path.join(test.get_temp_dir(), 'new_dir')
   args = self.parser.parse_args([
       'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
       'regress_x_to_y', '--input_examples', 'inputs=[{"x":[[1],[2]]}]',
       '--outdir', output_dir
   ])
   with self.assertRaisesRegexp(ValueError, 'is not supported'):
     saved_model_cli.run(args)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:11,代码来源:saved_model_cli_test.py


示例17: testRunCommandInputExamplesFeatureValueNotListError

 def testRunCommandInputExamplesFeatureValueNotListError(self):
   self.parser = saved_model_cli.create_parser()
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   output_dir = os.path.join(test.get_temp_dir(), 'new_dir')
   args = self.parser.parse_args([
       'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
       'regress_x_to_y', '--input_examples', 'inputs=[{"x":8.0,"x2":5.0}]',
       '--outdir', output_dir
   ])
   with self.assertRaisesRegexp(ValueError, 'feature value must be a list'):
     saved_model_cli.run(args)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:11,代码来源:saved_model_cli_test.py


示例18: testMetricsCollection

  def testMetricsCollection(self):

    def _enqueue_vector(sess, queue, values, shape=None):
      if not shape:
        shape = (1, len(values))
      dtype = queue.dtypes[0]
      sess.run(
          queue.enqueue(constant_op.constant(
              values, dtype=dtype, shape=shape)))

    meta_graph_filename = os.path.join(
        _TestDir("metrics_export"), "meta_graph.pb")

    graph = ops.Graph()
    with self.session(graph=graph) as sess:
      values_queue = data_flow_ops.FIFOQueue(
          4, dtypes.float32, shapes=(1, 2))
      _enqueue_vector(sess, values_queue, [0, 1])
      _enqueue_vector(sess, values_queue, [-4.2, 9.1])
      _enqueue_vector(sess, values_queue, [6.5, 0])
      _enqueue_vector(sess, values_queue, [-3.2, 4.0])
      values = values_queue.dequeue()

      _, update_op = metrics.mean(values)

      initializer = variables.local_variables_initializer()
      self.evaluate(initializer)
      self.evaluate(update_op)

    meta_graph.export_scoped_meta_graph(
        filename=meta_graph_filename, graph=graph)

    # Verifies that importing a meta_graph with LOCAL_VARIABLES collection
    # works correctly.
    graph = ops.Graph()
    with self.session(graph=graph) as sess:
      meta_graph.import_scoped_meta_graph(meta_graph_filename)
      initializer = variables.local_variables_initializer()
      self.evaluate(initializer)

    # Verifies that importing an old meta_graph where "local_variables"
    # collection is of node_list type works, but cannot build initializer
    # with the collection.
    graph = ops.Graph()
    with self.session(graph=graph) as sess:
      meta_graph.import_scoped_meta_graph(
          test.test_src_dir_path(
              "python/framework/testdata/metrics_export_meta_graph.pb"))
      self.assertEqual(len(ops.get_collection(ops.GraphKeys.LOCAL_VARIABLES)),
                       2)
      with self.assertRaisesRegexp(
          AttributeError, "'Tensor' object has no attribute 'initializer'"):
        initializer = variables.local_variables_initializer()
开发者ID:aeverall,项目名称:tensorflow,代码行数:53,代码来源:meta_graph_test.py


示例19: testRunCommandInputExamples

 def testRunCommandInputExamples(self):
   self.parser = saved_model_cli.create_parser()
   base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
   output_dir = os.path.join(test.get_temp_dir(), 'new_dir')
   args = self.parser.parse_args([
       'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
       'regress_x_to_y', '--input_examples',
       'inputs=[{"x":[8.0],"x2":[5.0]}, {"x":[4.0],"x2":[3.0]}]', '--outdir',
       output_dir
   ])
   saved_model_cli.run(args)
   y_actual = np.load(os.path.join(output_dir, 'outputs.npy'))
   y_expected = np.array([[6.0], [4.0]])
   self.assertAllEqual(y_expected, y_actual)
开发者ID:DILASSS,项目名称:tensorflow,代码行数:14,代码来源:saved_model_cli_test.py


示例20: testMatrixThatFailsWhenFlushingDenormsToZero

 def testMatrixThatFailsWhenFlushingDenormsToZero(self):
   # Test a 32x32 matrix which is known to fail if denorm floats are flushed to
   # zero.
   matrix = np.genfromtxt(
       test.test_src_dir_path(
           "python/kernel_tests/testdata/"
           "self_adjoint_eig_fail_if_denorms_flushed.txt")).astype(np.float32)
   self.assertEqual(matrix.shape, (32, 32))
   matrix_tensor = constant_op.constant(matrix)
   with self.session(use_gpu=True) as sess:
     (e, v) = sess.run(linalg_ops.self_adjoint_eig(matrix_tensor))
     self.assertEqual(e.size, 32)
     self.assertAllClose(
         np.matmul(v, v.transpose()), np.eye(32, dtype=np.float32), atol=2e-3)
     self.assertAllClose(matrix,
                         np.matmul(np.matmul(v, np.diag(e)), v.transpose()))
开发者ID:bunbutter,项目名称:tensorflow,代码行数:16,代码来源:self_adjoint_eig_op_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tf_logging.debug函数代码示例发布时间:2022-05-27
下一篇:
Python test.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap