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


Python config_pb2.RunOptions方法代码示例

本文整理汇总了Python中tensorflow.core.protobuf.config_pb2.RunOptions方法的典型用法代码示例。如果您正苦于以下问题:Python config_pb2.RunOptions方法的具体用法?Python config_pb2.RunOptions怎么用?Python config_pb2.RunOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.core.protobuf.config_pb2的用法示例。


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

示例1: testDebugWhileLoopWatchingWholeGraphWorks

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testDebugWhileLoopWatchingWholeGraphWorks(self):
    with session.Session() as sess:
      loop_body = lambda i: math_ops.add(i, 2)
      loop_cond = lambda i: math_ops.less(i, 16)

      i = constant_op.constant(10, name="i")
      loop = control_flow_ops.while_loop(loop_cond, loop_body, [i])

      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      debug_utils.watch_graph(run_options,
                              sess.graph,
                              debug_urls=self._debug_urls())
      run_metadata = config_pb2.RunMetadata()
      self.assertEqual(
          16, sess.run(loop, options=run_options, run_metadata=run_metadata))

      dump = debug_data.DebugDumpDir(
          self._dump_root, partition_graphs=run_metadata.partition_graphs)

      self.assertEqual(
          [[10]], dump.get_tensors("while/Enter", 0, "DebugIdentity"))
      self.assertEqual(
          [[12], [14], [16]],
          dump.get_tensors("while/NextIteration", 0, "DebugIdentity")) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:session_debug_testlib.py

示例2: testDebugQueueOpsDoesNotoErrorOut

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testDebugQueueOpsDoesNotoErrorOut(self):
    with session.Session() as sess:
      q = data_flow_ops.FIFOQueue(3, "float", name="fifo_queue")
      q_init = q.enqueue_many(([101.0, 202.0, 303.0],), name="enqueue_many")

      run_metadata = config_pb2.RunMetadata()
      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      debug_utils.watch_graph(
          run_options,
          sess.graph,
          debug_urls=self._debug_urls())

      sess.run(q_init, options=run_options, run_metadata=run_metadata)

      dump = debug_data.DebugDumpDir(
          self._dump_root, partition_graphs=run_metadata.partition_graphs)
      self.assertTrue(dump.loaded_partition_graphs())

      fifo_queue_tensor = dump.get_tensors("fifo_queue", 0, "DebugIdentity")[0]
      self.assertIsInstance(fifo_queue_tensor,
                            debug_data.InconvertibleTensorProto)
      self.assertTrue(fifo_queue_tensor.initialized)
      self.assertAllClose(
          [101.0, 202.0, 303.0],
          dump.get_tensors("enqueue_many/component_0", 0, "DebugIdentity")[0]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:27,代码来源:session_debug_testlib.py

示例3: _prepare_cont_call_dump_path_and_run_options

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def _prepare_cont_call_dump_path_and_run_options(self):
    """Prepare the dump path and RunOptions for next cont() call.

    Returns:
      dump_path: (str) Directory path to which the intermediate tensor will be
        dumped.
      run_options: (config_pb2.RunOptions) The RunOptions containing the tensor
        watch options for this graph.
    """
    run_options = config_pb2.RunOptions()
    dump_path = self._cont_call_dump_path()
    for element_name in self._closure_elements:
      if ":" in element_name:
        debug_utils.add_debug_tensor_watch(
            run_options,
            debug_data.get_node_name(element_name),
            output_slot=debug_data.get_output_slot(element_name),
            debug_urls=["file://" + dump_path])

    return dump_path, run_options 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:22,代码来源:stepper.py

示例4: __init__

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
               run_call_count):
    """Constructor of `OnRunStartRequest`.

    Args:
      fetches: Fetch targets of the run() call.
      feed_dict: The feed dictionary to the run() call.
      run_options: RunOptions input to the run() call.
      run_metadata: RunMetadata input to the run() call.
        The above four arguments are identical to the input arguments to the
        run() method of a non-wrapped TensorFlow session.
      run_call_count: 1-based count of how many run calls (including this one)
        has been invoked.
    """
    self.fetches = fetches
    self.feed_dict = feed_dict
    self.run_options = run_options
    self.run_metadata = run_metadata
    self.run_call_count = run_call_count 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:framework.py

示例5: _merge_run_options

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def _merge_run_options(self, options, incoming_options):
    """Merge two instances of RunOptions into the first one.

    During the merger, the numerical fields including trace_level,
    timeout_in_ms, inter_op_thread_pool are set to the larger one of the two.
    The boolean value is set to the logical OR of the two.
    debug_tensor_watch_opts of the original options is extended with that from
    the incoming one.

    Args:
      options: The options to merge into.
      incoming_options: The options to be merged into the first argument.
    """
    options.trace_level = max(options.trace_level, incoming_options.trace_level)
    options.timeout_in_ms = max(options.timeout_in_ms,
                                incoming_options.timeout_in_ms)
    options.inter_op_thread_pool = max(options.inter_op_thread_pool,
                                       incoming_options.inter_op_thread_pool)
    options.output_partition_graphs = max(
        options.output_partition_graphs,
        incoming_options.output_partition_graphs)

    options.debug_options.debug_tensor_watch_opts.extend(
        incoming_options.debug_options.debug_tensor_watch_opts) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:monitored_session.py

示例6: __init__

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
               run_call_count):
    """Constructor of OnRunStartRequest.

    Args:
      fetches: Fetch targets of the run() call.
      feed_dict: The feed dictionary to the run() call.
      run_options: RunOptions input to the run() call.
      run_metadata: RunMetadata input to the run() call.
        The above four arguments are identical to the input arguments to the
        run() method of a non-wrapped TensorFlow session.
      run_call_count: 1-based count of how many run calls (including this one)
        has been invoked.
    """
    self.fetches = fetches
    self.feed_dict = feed_dict
    self.run_options = run_options
    self.run_metadata = run_metadata
    self.run_call_count = run_call_count 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:21,代码来源:framework.py

示例7: testPerStepTrace

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testPerStepTrace(self):
    run_options = config_pb2.RunOptions(
        trace_level=config_pb2.RunOptions.FULL_TRACE)
    run_metadata = config_pb2.RunMetadata()

    with ops.device('/cpu:0'):
      with session.Session() as sess:
        sess.run(constant_op.constant(1.0))
        self.assertTrue(not run_metadata.HasField('step_stats'))

        sess.run(constant_op.constant(1.0), run_metadata=run_metadata)
        self.assertTrue(not run_metadata.HasField('step_stats'))

        sess.run(constant_op.constant(1.0),
                 options=run_options,
                 run_metadata=run_metadata)

        self.assertTrue(run_metadata.HasField('step_stats'))
        self.assertEquals(len(run_metadata.step_stats.dev_stats), 1) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:21,代码来源:session_test.py

示例8: testRunOptionsRunMetadata

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testRunOptionsRunMetadata(self):
    run_options = config_pb2.RunOptions(
        trace_level=config_pb2.RunOptions.FULL_TRACE)
    run_metadata = config_pb2.RunMetadata()

    with ops.device('/cpu:0'):
      with session.Session() as sess:
        # all combinations are valid
        sess.run(constant_op.constant(1.0), options=None, run_metadata=None)
        sess.run(constant_op.constant(1.0), options=None,
                 run_metadata=run_metadata)
        self.assertTrue(not run_metadata.HasField('step_stats'))

        sess.run(constant_op.constant(1.0), options=run_options,
                 run_metadata=None)
        self.assertTrue(not run_metadata.HasField('step_stats'))

        sess.run(constant_op.constant(1.0), options=run_options,
                 run_metadata=run_metadata)

        self.assertTrue(run_metadata.HasField('step_stats'))
        self.assertEquals(len(run_metadata.step_stats.dev_stats), 1) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:24,代码来源:session_test.py

示例9: testBuildCostModel

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testBuildCostModel(self):
    run_options = config_pb2.RunOptions()
    config = config_pb2.ConfigProto(
        allow_soft_placement=True,
        graph_options=config_pb2.GraphOptions(build_cost_model=100))
    with session.Session(config=config) as sess:
      with ops.device('/gpu:0'):
        a = array_ops.placeholder(dtypes.float32, shape=[])
        b = math_ops.add(a, a)
        c = array_ops.identity(b)
        d = math_ops.mul(c, c)
      for step in xrange(120):
        run_metadata = config_pb2.RunMetadata()
        sess.run(d, feed_dict={a: 1.0},
                 options=run_options, run_metadata=run_metadata)
        if step == 99:
          self.assertTrue(run_metadata.HasField('cost_graph'))
        else:
          self.assertFalse(run_metadata.HasField('cost_graph')) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:21,代码来源:session_test.py

示例10: _prepare_cont_call_dump_path_and_run_options

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def _prepare_cont_call_dump_path_and_run_options(self):
    """Prepare the dump path and RunOptions for next cont() call.

    Returns:
      dump_path: (str) Directory path to which the intermediate tensor will be
        dumped.
      run_options: (config_pb2.RunOptions) The RunOptions containing the tensor
        watch options for this graph.
    """
    run_options = config_pb2.RunOptions()
    dump_path = self._cont_call_dump_path()
    for element_name in self._closure_elements:
      if ":" in element_name:
        debug_utils.add_debug_tensor_watch(
            run_options,
            debug_graphs.get_node_name(element_name),
            output_slot=debug_graphs.get_output_slot(element_name),
            debug_urls=["file://" + dump_path])

    return dump_path, run_options 
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:22,代码来源:stepper.py

示例11: __init__

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def __init__(self, fetches, feed_dict, run_options, run_metadata,
               run_call_count, is_callable_runner=False):
    """Constructor of `OnRunStartRequest`.

    Args:
      fetches: Fetch targets of the run() call.
      feed_dict: The feed dictionary to the run() call.
      run_options: RunOptions input to the run() call.
      run_metadata: RunMetadata input to the run() call.
        The above four arguments are identical to the input arguments to the
        run() method of a non-wrapped TensorFlow session.
      run_call_count: 1-based count of how many run calls (including this one)
        has been invoked.
      is_callable_runner: (bool) whether a runner returned by
        Session.make_callable is being run.
    """
    self.fetches = fetches
    self.feed_dict = feed_dict
    self.run_options = run_options
    self.run_metadata = run_metadata
    self.run_call_count = run_call_count
    self.is_callable_runner = is_callable_runner 
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:24,代码来源:framework.py

示例12: testDebugTrainingDynamicRNNWorks

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testDebugTrainingDynamicRNNWorks(self):
    with session.Session() as sess:
      input_size = 3
      state_size = 2
      time_steps = 4
      batch_size = 2

      input_values = np.random.randn(time_steps, batch_size, input_size)
      sequence_length = np.random.randint(0, time_steps, size=batch_size)
      concat_inputs = array_ops.placeholder(
          dtypes.float32, shape=(time_steps, batch_size, input_size))

      outputs_dynamic, _ = rnn.dynamic_rnn(
          _RNNCellForTest(input_size, state_size),
          inputs=concat_inputs,
          sequence_length=sequence_length,
          time_major=True,
          dtype=dtypes.float32)
      toy_loss = math_ops.reduce_sum(outputs_dynamic * outputs_dynamic)
      train_op = gradient_descent.GradientDescentOptimizer(
          learning_rate=0.1).minimize(toy_loss, name="train_op")

      sess.run(variables.global_variables_initializer())

      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      debug_utils.watch_graph_with_blacklists(
          run_options,
          sess.graph,
          node_name_regex_blacklist="(.*rnn/while/.*|.*TensorArray.*)",
          debug_urls=self._debug_urls())
      # b/36870549: Nodes with these name patterns need to be excluded from
      # tfdbg in order to prevent MSAN warnings of uninitialized Tensors
      # under both file:// and grpc:// debug URL schemes.

      run_metadata = config_pb2.RunMetadata()
      sess.run(train_op, feed_dict={concat_inputs: input_values},
               options=run_options, run_metadata=run_metadata)

      debug_data.DebugDumpDir(
          self._dump_root, partition_graphs=run_metadata.partition_graphs) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:42,代码来源:session_debug_testlib.py

示例13: _session_run_for_graph_structure_lookup

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def _session_run_for_graph_structure_lookup(self):
    with session.Session() as sess:
      u_name = "testDumpGraphStructureLookup/u"
      v_name = "testDumpGraphStructureLookup/v"
      w_name = "testDumpGraphStructureLookup/w"

      u_init = constant_op.constant([2.0, 4.0])
      u = variables.Variable(u_init, name=u_name)
      v = math_ops.add(u, u, name=v_name)
      w = math_ops.add(v, v, name=w_name)

      u.initializer.run()

      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      debug_utils.watch_graph(
          run_options,
          sess.graph,
          debug_ops=["DebugIdentity"],
          debug_urls=self._debug_urls())

      run_metadata = config_pb2.RunMetadata()
      sess.run(w, options=run_options, run_metadata=run_metadata)

    self.assertEqual(self._expected_partition_graph_count,
                     len(run_metadata.partition_graphs))

    dump = debug_data.DebugDumpDir(
        self._dump_root, partition_graphs=run_metadata.partition_graphs)

    return u_name, v_name, w_name, dump 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:32,代码来源:session_debug_testlib.py

示例14: testWatchingOnlyOneOfTwoOutputSlotsDoesNotLeadToCausalityFailure

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testWatchingOnlyOneOfTwoOutputSlotsDoesNotLeadToCausalityFailure(self):
    with session.Session() as sess:
      x_name = "oneOfTwoSlots/x"
      u_name = "oneOfTwoSlots/u"
      v_name = "oneOfTwoSlots/v"
      w_name = "oneOfTwoSlots/w"
      y_name = "oneOfTwoSlots/y"

      x = variables.Variable([1, 3, 3, 7], dtype=dtypes.int32, name=x_name)
      sess.run(x.initializer)

      unique_x, indices, _ = array_ops.unique_with_counts(x, name=u_name)

      v = math_ops.add(unique_x, unique_x, name=v_name)
      w = math_ops.add(indices, indices, name=w_name)
      y = math_ops.add(w, w, name=y_name)

      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      # Watch only the first output slot of u, even though it has two output
      # slots.
      debug_utils.add_debug_tensor_watch(
          run_options, u_name, 0, debug_urls=self._debug_urls())
      debug_utils.add_debug_tensor_watch(
          run_options, w_name, 0, debug_urls=self._debug_urls())
      debug_utils.add_debug_tensor_watch(
          run_options, y_name, 0, debug_urls=self._debug_urls())

      run_metadata = config_pb2.RunMetadata()
      sess.run([v, y], options=run_options, run_metadata=run_metadata)

      dump = debug_data.DebugDumpDir(
          self._dump_root,
          partition_graphs=run_metadata.partition_graphs,
          validate=True)

      self.assertAllClose([1, 3, 7],
                          dump.get_tensors(u_name, 0, "DebugIdentity")[0]) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:39,代码来源:session_debug_testlib.py

示例15: testOutputSlotWithoutOutgoingEdgeCanBeWatched

# 需要导入模块: from tensorflow.core.protobuf import config_pb2 [as 别名]
# 或者: from tensorflow.core.protobuf.config_pb2 import RunOptions [as 别名]
def testOutputSlotWithoutOutgoingEdgeCanBeWatched(self):
    """Test watching output slots not attached to any outgoing edges."""

    with session.Session() as sess:
      u_init_val = np.array([[5.0, 3.0], [-1.0, 0.0]])
      u = constant_op.constant(u_init_val, shape=[2, 2], name="u")

      # Create a control edge from a node with an output: From u to z.
      # Node u will get executed only because of the control edge. The output
      # tensor u:0 is not attached to any outgoing edge in the graph. This test
      # checks that the debugger can watch such a tensor.
      with ops.control_dependencies([u]):
        z = control_flow_ops.no_op(name="z")

      run_options = config_pb2.RunOptions(output_partition_graphs=True)
      debug_utils.watch_graph(
          run_options,
          sess.graph,
          debug_ops=["DebugIdentity"],
          debug_urls=self._debug_urls())

      run_metadata = config_pb2.RunMetadata()
      sess.run(z, options=run_options, run_metadata=run_metadata)

      dump = debug_data.DebugDumpDir(
          self._dump_root, partition_graphs=run_metadata.partition_graphs)

      # Assert that the DebugIdentity watch on u works properly.
      self.assertEqual(1, len(dump.dumped_tensor_data))
      datum = dump.dumped_tensor_data[0]
      self.assertEqual("u", datum.node_name)
      self.assertEqual(0, datum.output_slot)
      self.assertEqual("DebugIdentity", datum.debug_op)
      self.assertAllClose([[5.0, 3.0], [-1.0, 0.0]], datum.get_tensor()) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:36,代码来源:session_debug_testlib.py


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