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


Python test.test_src_dir_path函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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