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


Python meta_graph.create_meta_graph_def方法代码示例

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


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

示例1: before_run

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def before_run(self, run_context):  # pylint: disable=unused-argument
    if self._timer.last_triggered_step() is None:
      # We do write graph and saver_def at the first call of before_run.
      # We cannot do this in begin, since we let other hooks to change graph and
      # add variables in begin. Graph is finalized after all begin calls.
      training_util.write_graph(
          ops.get_default_graph().as_graph_def(add_shapes=True),
          self._checkpoint_dir,
          "graph.pbtxt")
      saver_def = self._get_saver().saver_def if self._get_saver() else None
      graph = ops.get_default_graph()
      meta_graph_def = meta_graph.create_meta_graph_def(
          graph_def=graph.as_graph_def(add_shapes=True),
          saver_def=saver_def)
      self._summary_writer.add_graph(graph)
      self._summary_writer.add_meta_graph(meta_graph_def)

    return SessionRunArgs(self._global_step_tensor) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:basic_session_run_hooks.py

示例2: after_create_session

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def after_create_session(self, session, coord):
    global_step = session.run(self._global_step_tensor)

    # We do write graph and saver_def at the first call of before_run.
    # We cannot do this in begin, since we let other hooks to change graph and
    # add variables in begin. Graph is finalized after all begin calls.
    def _write_graph_fn(self):
      training_util.write_graph(
          ops.get_default_graph().as_graph_def(add_shapes=True),
          self._checkpoint_dir, "graph.pbtxt")
    self._write_graph_thread = threading.Thread(target=_write_graph_fn,
                                                args=[self])
    self._write_graph_thread.start()

    saver_def = self._get_saver().saver_def if self._get_saver() else None
    graph = ops.get_default_graph()
    meta_graph_def = meta_graph.create_meta_graph_def(
        graph_def=graph.as_graph_def(add_shapes=True), saver_def=saver_def)
    self._summary_writer.add_graph(graph)
    self._summary_writer.add_meta_graph(meta_graph_def)
    # The checkpoint saved here is the state at step "global_step".
    self._save(session, global_step)
    self._timer.update_last_triggered_step(global_step) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:25,代码来源:async_checkpoint.py

示例3: before_run

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def before_run(self, run_context):  # pylint: disable=unused-argument
    if self._timer.last_triggered_step() is None:
      # Write graph in the first call.
      training_util.write_graph(
          ops.get_default_graph().as_graph_def(add_shapes=True),
          self._checkpoint_dir,
          "graph.pbtxt")
      saver_def = self._saver.saver_def if self._saver else None
      graph = ops.get_default_graph()
      meta_graph_def = meta_graph.create_meta_graph_def(
          graph_def=graph.as_graph_def(add_shapes=True),
          saver_def=saver_def)
      self._summary_writer.add_graph(graph)
      self._summary_writer.add_meta_graph(meta_graph_def)

    return SessionRunArgs(self._global_step_tensor) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:18,代码来源:basic_session_run_hooks.py

示例4: test_train

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def test_train(self):
    with tf.Graph().as_default() as g, self.test_session(g):
      with tf.control_dependencies(self._build_inference_graph()):
        train_op = tf.assign_add(tf.contrib.framework.get_global_step(), 1)
      self._assert_summaries(self._output_dir)
      self._assert_ckpt(self._output_dir, False)
      loss = learn.graph_actions._monitored_train(  # pylint: disable=protected-access
          g,
          output_dir=self._output_dir,
          train_op=train_op,
          loss_op=tf.constant(2.0),
          steps=1)
      meta_graph_def = meta_graph.create_meta_graph_def()
      self.assertEqual(2.0, loss)
      self._assert_summaries(self._output_dir, expected_graphs=[g],
                             expected_meta_graphs=[meta_graph_def])
      self._assert_ckpt(self._output_dir, True) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:19,代码来源:graph_actions_test.py

示例5: test_train_loss

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def test_train_loss(self):
    with tf.Graph().as_default() as g, self.test_session(g):
      tf.contrib.framework.create_global_step()
      loss_var = tf.contrib.framework.local_variable(10.0)
      train_op = tf.group(
          tf.assign_add(tf.contrib.framework.get_global_step(), 1),
          tf.assign_add(loss_var, -1.0))
      self._assert_summaries(self._output_dir)
      self._assert_ckpt(self._output_dir, False)
      loss = learn.graph_actions._monitored_train(  # pylint: disable=protected-access
          g,
          output_dir=self._output_dir,
          train_op=train_op,
          loss_op=loss_var.value(),
          steps=6)
      meta_graph_def = meta_graph.create_meta_graph_def()
      self.assertEqual(4.0, loss)
      self._assert_summaries(self._output_dir, expected_graphs=[g],
                             expected_meta_graphs=[meta_graph_def])
      self._assert_ckpt(self._output_dir, True) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:22,代码来源:graph_actions_test.py

示例6: test_train_summaries

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def test_train_summaries(self):
    with tf.Graph().as_default() as g, self.test_session(g):
      with tf.control_dependencies(self._build_inference_graph()):
        train_op = tf.assign_add(tf.contrib.framework.get_global_step(), 1)
      loss_op = tf.constant(2.0)
      tf.summary.scalar('loss', loss_op)
      self._assert_summaries(self._output_dir)
      self._assert_ckpt(self._output_dir, False)
      loss = learn.graph_actions._monitored_train(  # pylint: disable=protected-access
          g,
          output_dir=self._output_dir,
          train_op=train_op,
          loss_op=loss_op,
          steps=1)
      meta_graph_def = meta_graph.create_meta_graph_def()
      self.assertEqual(2.0, loss)
      self._assert_summaries(self._output_dir,
                             expected_graphs=[g],
                             expected_meta_graphs=[meta_graph_def],
                             expected_summaries={1: {'loss': 2.0}})
      self._assert_ckpt(self._output_dir, True) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:23,代码来源:graph_actions_test.py

示例7: test_summary_writer_defs

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def test_summary_writer_defs(self):
    fake_summary_writer.FakeSummaryWriter.install()
    tf.compat.v1.summary.FileWriterCache.clear()
    summary_writer = tf.compat.v1.summary.FileWriterCache.get(self.model_dir)

    with self.graph.as_default():
      hook = basic_session_run_hooks.CheckpointSaverHook(
          self.model_dir, save_steps=2, scaffold=self.scaffold)
      hook.begin()
      self.scaffold.finalize()
      with tf.compat.v1.Session() as sess:
        sess.run(self.scaffold.init_op)
        mon_sess = monitored_session._HookedSession(sess, [hook])
        hook.after_create_session(sess, None)
        mon_sess.run(self.train_op)
      summary_writer.assert_summaries(
          test_case=self,
          expected_logdir=self.model_dir,
          expected_added_meta_graphs=[
              meta_graph.create_meta_graph_def(
                  graph_def=self.graph.as_graph_def(add_shapes=True),
                  saver_def=self.scaffold.saver.saver_def)
          ])

    fake_summary_writer.FakeSummaryWriter.uninstall() 
开发者ID:tensorflow,项目名称:estimator,代码行数:27,代码来源:basic_session_run_hooks_test.py

示例8: before_run

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def before_run(self, run_context):
        """ Dumps graphs and loads checkpoint if there exits.

        Called before each call to run().

        Args:
            run_context: A `SessionRunContext` object.

        Returns: A `SessionRunArgs` object containing global_step.
        """
        # We do write graph and saver_def at the first call of before_run.
        # We cannot do this in begin, since we let other hooks to change graph and
        # add variables in begin. Graph is finalized after all begin calls.
        if self._is_chief and self._first_call:
            training_util.write_graph(
                ops.get_default_graph().as_graph_def(add_shapes=True),
                self._checkpoint_dir,
                "graph.pbtxt")
            # dump model details "model_analysis.txt"
            dump_model_analysis(self._checkpoint_dir)  # dump model configs
            graph = ops.get_default_graph()
            meta_graph_def = meta_graph.create_meta_graph_def(
                graph_def=graph.as_graph_def(add_shapes=True),
                saver_def=self._saver.saver_def)
            if self._summary_writer is not None:
                self._summary_writer.add_graph(graph)
                self._summary_writer.add_meta_graph(meta_graph_def)
            tf.logging.info("CheckpointSaverHook (before_run): dump graph...")
        self._first_call = False
        return tf.train.SessionRunArgs(self._global_step) 
开发者ID:zhaocq-nlp,项目名称:NJUNMT-tf,代码行数:32,代码来源:hooks.py

示例9: __init__

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def __init__(self, event_writer, graph=None, graph_def=None):
    """Creates a `SummaryWriter` and an event file.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers constructed when you
    call one of the following functions: `add_summary()`, `add_session_log()`,
    `add_event()`, or `add_graph()`.

    If you pass a `Graph` to the constructor it is added to
    the event file. (This is equivalent to calling `add_graph()` later).

    TensorBoard will pick the graph from the file and display it graphically so
    you can interactively explore the graph you built. You will usually pass
    the graph from the session in which you launched it:

    ```python
    ...create a graph...
    # Launch the graph in a session.
    sess = tf.Session()
    # Create a summary writer, add the 'graph' to the event file.
    writer = tf.summary.FileWriter(<some-directory>, sess.graph)
    ```


    Args:
      event_writer: An EventWriter. Implements add_event and get_logdir.
      graph: A `Graph` object, such as `sess.graph`.
      graph_def: DEPRECATED: Use the `graph` argument instead.
    """
    self.event_writer = event_writer
    # For storing used tags for session.run() outputs.
    self._session_run_tags = {}
    if graph is not None or graph_def is not None:
      # Calling it with both graph and graph_def for backward compatibility.
      self.add_graph(graph=graph, graph_def=graph_def)
      # Also export the meta_graph_def in this case.
      # graph may itself be a graph_def due to positional arguments
      maybe_graph_as_def = (graph.as_graph_def(add_shapes=True)
                            if isinstance(graph, ops.Graph) else graph)
      self.add_meta_graph(
          meta_graph.create_meta_graph_def(graph_def=graph_def or
                                           maybe_graph_as_def)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:44,代码来源:writer.py

示例10: __init__

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def __init__(self, event_writer, graph=None, graph_def=None):
    """Creates a `SummaryWriter` and an event file.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers constructed when you
    call one of the following functions: `add_summary()`, `add_session_log()`,
    `add_event()`, or `add_graph()`.

    If you pass a `Graph` to the constructor it is added to
    the event file. (This is equivalent to calling `add_graph()` later).

    TensorBoard will pick the graph from the file and display it graphically so
    you can interactively explore the graph you built. You will usually pass
    the graph from the session in which you launched it:

    ```python
    ...create a graph...
    # Launch the graph in a session.
    sess = tf.Session()
    # Create a summary writer, add the 'graph' to the event file.
    writer = tf.summary.FileWriter(<some-directory>, sess.graph)
    ```


    Args:
      event_writer: An EventWriter. Implements add_event method.
      graph: A `Graph` object, such as `sess.graph`.
      graph_def: DEPRECATED: Use the `graph` argument instead.
    """
    self.event_writer = event_writer
    # For storing used tags for session.run() outputs.
    self._session_run_tags = {}
    if graph is not None or graph_def is not None:
      # Calling it with both graph and graph_def for backward compatibility.
      self.add_graph(graph=graph, graph_def=graph_def)
      # Also export the meta_graph_def in this case.
      # graph may itself be a graph_def due to positional arguments
      maybe_graph_as_def = (
          graph.as_graph_def(add_shapes=True) if isinstance(graph, ops.Graph)
          else graph)
      self.add_meta_graph(
          meta_graph.create_meta_graph_def(
              graph_def=graph_def or maybe_graph_as_def)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:45,代码来源:writer.py

示例11: testChiefCanWriteEvents

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def testChiefCanWriteEvents(self):
    logdir = _test_dir("can_write")
    with tf.Graph().as_default():
      tf.summary.scalar("c1", tf.constant(1))
      tf.summary.scalar("c2", tf.constant(2))
      tf.summary.scalar("c3", tf.constant(3))
      summ = tf.summary.merge_all()
      sv = tf.train.Supervisor(is_chief=True, logdir=logdir, summary_op=None)
      meta_graph_def = meta_graph.create_meta_graph_def()
      sess = sv.prepare_or_wait_for_session("")
      sv.summary_computed(sess, sess.run(summ))
      sess.close()
      # Wait to make sure everything is written to file before stopping.
      time.sleep(1)
      sv.stop()

    rr = _summary_iterator(logdir)

    # The first event should list the file_version.
    ev = next(rr)
    self.assertEquals("brain.Event:2", ev.file_version)

    # The next one has the graph.
    ev = next(rr)
    ev_graph = tf.GraphDef()
    ev_graph.ParseFromString(ev.graph_def)
    self.assertProtoEquals(sess.graph.as_graph_def(add_shapes=True), ev_graph)

    # Stored MetaGraphDef
    ev = next(rr)
    ev_meta_graph = meta_graph_pb2.MetaGraphDef()
    ev_meta_graph.ParseFromString(ev.meta_graph_def)
    self.assertProtoEquals(meta_graph_def, ev_meta_graph)
    self.assertProtoEquals(
        sess.graph.as_graph_def(add_shapes=True), ev_meta_graph.graph_def)
    # The next one should have the values from the summary.
    ev = next(rr)
    self.assertProtoEquals("""
      value { tag: 'c1' simple_value: 1.0 }
      value { tag: 'c2' simple_value: 2.0 }
      value { tag: 'c3' simple_value: 3.0 }
      """, ev.summary)

    # The next one should be a stop message if we closed cleanly.
    ev = next(rr)
    self.assertEquals(tf.SessionLog.STOP, ev.session_log.status)

    # We should be done.
    self.assertRaises(StopIteration, lambda: next(rr)) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:51,代码来源:supervisor_test.py

示例12: testNoLogdirButExplicitSummaryWriter

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def testNoLogdirButExplicitSummaryWriter(self):
    logdir = _test_dir("explicit_summary_writer")
    with tf.Graph().as_default():
      tf.summary.scalar("c1", tf.constant(1))
      tf.summary.scalar("c2", tf.constant(2))
      tf.summary.scalar("c3", tf.constant(3))
      summ = tf.summary.merge_all()
      sw = tf.train.SummaryWriter(logdir)
      sv = tf.train.Supervisor(logdir="", summary_op=None, summary_writer=sw)
      meta_graph_def = meta_graph.create_meta_graph_def()
      sess = sv.prepare_or_wait_for_session("")
      sv.summary_computed(sess, sess.run(summ))
      sess.close()
      # Wait to make sure everything is written to file before stopping.
      time.sleep(1)
      sv.stop()

    # Check the summary was written to 'logdir'
    rr = _summary_iterator(logdir)

    # The first event should list the file_version.
    ev = next(rr)
    self.assertEquals("brain.Event:2", ev.file_version)

    # The next one has the graph.
    ev = next(rr)
    ev_graph = tf.GraphDef()
    ev_graph.ParseFromString(ev.graph_def)
    self.assertProtoEquals(sess.graph.as_graph_def(add_shapes=True), ev_graph)

    # Stored MetaGraphDef
    ev = next(rr)
    ev_meta_graph = meta_graph_pb2.MetaGraphDef()
    ev_meta_graph.ParseFromString(ev.meta_graph_def)
    self.assertProtoEquals(meta_graph_def, ev_meta_graph)
    self.assertProtoEquals(
        sess.graph.as_graph_def(add_shapes=True), ev_meta_graph.graph_def)

    # The next one should have the values from the summary.
    ev = next(rr)
    self.assertProtoEquals("""
      value { tag: 'c1' simple_value: 1.0 }
      value { tag: 'c2' simple_value: 2.0 }
      value { tag: 'c3' simple_value: 3.0 }
      """, ev.summary)

    # The next one should be a stop message if we closed cleanly.
    ev = next(rr)
    self.assertEquals(tf.SessionLog.STOP, ev.session_log.status)

    # We should be done.
    self.assertRaises(StopIteration, lambda: next(rr)) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:54,代码来源:supervisor_test.py

示例13: testStandardServicesWithoutGlobalStep

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def testStandardServicesWithoutGlobalStep(self):
    logdir = _test_dir("standard_services_without_global_step")
    # Create a checkpoint.
    with tf.Graph().as_default():
      v = tf.Variable([1.0], name="foo")
      tf.summary.scalar("v", v[0])
      sv = tf.train.Supervisor(logdir=logdir)
      meta_graph_def = meta_graph.create_meta_graph_def(
          saver_def=sv.saver.saver_def)
      sess = sv.prepare_or_wait_for_session("")
      save_path = sv.save_path
      self._wait_for_glob(save_path, 3.0)
      self._wait_for_glob(
          os.path.join(logdir, "*events*"), 3.0, for_checkpoint=False)
      # Wait to make sure everything is written to file before stopping.
      time.sleep(1)
      sv.stop()
    # There should be an event file with a version number.
    rr = _summary_iterator(logdir)
    ev = next(rr)
    self.assertEquals("brain.Event:2", ev.file_version)
    ev = next(rr)
    ev_graph = tf.GraphDef()
    ev_graph.ParseFromString(ev.graph_def)
    self.assertProtoEquals(sess.graph.as_graph_def(add_shapes=True), ev_graph)

    # Stored MetaGraphDef
    ev = next(rr)
    ev_meta_graph = meta_graph_pb2.MetaGraphDef()
    ev_meta_graph.ParseFromString(ev.meta_graph_def)
    self.assertProtoEquals(meta_graph_def, ev_meta_graph)
    self.assertProtoEquals(
        sess.graph.as_graph_def(add_shapes=True), ev_meta_graph.graph_def)

    ev = next(rr)
    self.assertProtoEquals("value { tag: 'v' simple_value: 1.0 }", ev.summary)

    ev = next(rr)
    self.assertEquals(tf.SessionLog.STOP, ev.session_log.status)

    self.assertRaises(StopIteration, lambda: next(rr))
    # There should be a checkpoint file with the variable "foo"
    with tf.Graph().as_default(), self.test_session() as sess:
      v = tf.Variable([10.10], name="foo")
      sav = tf.train.Saver([v])
      sav.restore(sess, save_path)
      self.assertEqual(1.0, v.eval()[0])

  # Same as testStandardServicesNoGlobalStep but with a global step.
  # We should get a summary about the step time. 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:52,代码来源:supervisor_test.py

示例14: testStandardServicesWithGlobalStep

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def testStandardServicesWithGlobalStep(self):
    logdir = _test_dir("standard_services_with_global_step")
    # Create a checkpoint.
    with tf.Graph().as_default():
      v = tf.Variable([123], name="global_step")
      sv = tf.train.Supervisor(logdir=logdir)
      meta_graph_def = meta_graph.create_meta_graph_def(
          saver_def=sv.saver.saver_def)
      sess = sv.prepare_or_wait_for_session("")
      # This is where the checkpoint will appear, with step number 123.
      save_path = "%s-123" % sv.save_path
      self._wait_for_glob(save_path, 3.0)
      self._wait_for_glob(
          os.path.join(logdir, "*events*"), 3.0, for_checkpoint=False)
      # Wait to make sure everything is written to file before stopping.
      time.sleep(1)
      sv.stop()
    # There should be an event file with a version number.
    rr = _summary_iterator(logdir)
    ev = next(rr)
    self.assertEquals("brain.Event:2", ev.file_version)
    ev = next(rr)
    ev_graph = tf.GraphDef()
    ev_graph.ParseFromString(ev.graph_def)
    self.assertProtoEquals(sess.graph.as_graph_def(add_shapes=True), ev_graph)
    ev = next(rr)
    ev_meta_graph = meta_graph_pb2.MetaGraphDef()
    ev_meta_graph.ParseFromString(ev.meta_graph_def)
    self.assertProtoEquals(meta_graph_def, ev_meta_graph)
    self.assertProtoEquals(
        sess.graph.as_graph_def(add_shapes=True), ev_meta_graph.graph_def)
    ev = next(rr)
    # It is actually undeterministic whether SessionLog.START gets written
    # before the summary or the checkpoint, but this works when run 10000 times.
    self.assertEquals(123, ev.step)
    self.assertEquals(tf.SessionLog.START, ev.session_log.status)
    first = next(rr)
    second = next(rr)
    # It is undeterministic whether the value gets written before the checkpoint
    # since they are on separate threads, so we check for both conditions.
    if first.HasField("summary"):
      self.assertProtoEquals("""value { tag: 'global_step/sec'
                                        simple_value: 0.0 }""",
                             first.summary)
      self.assertEquals(123, second.step)
      self.assertEquals(tf.SessionLog.CHECKPOINT, second.session_log.status)
    else:
      self.assertEquals(123, first.step)
      self.assertEquals(tf.SessionLog.CHECKPOINT, first.session_log.status)
      self.assertProtoEquals("""value { tag: 'global_step/sec'
                                        simple_value: 0.0 }""",
                             second.summary)
    ev = next(rr)
    self.assertEquals(tf.SessionLog.STOP, ev.session_log.status)
    self.assertRaises(StopIteration, lambda: next(rr))
    # There should be a checkpoint file with the variable "foo"
    with tf.Graph().as_default(), self.test_session() as sess:
      v = tf.Variable([-12], name="global_step")
      sav = tf.train.Saver([v])
      sav.restore(sess, save_path)
      self.assertEqual(123, v.eval()[0]) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:63,代码来源:supervisor_test.py

示例15: __init__

# 需要导入模块: from tensorflow.python.framework import meta_graph [as 别名]
# 或者: from tensorflow.python.framework.meta_graph import create_meta_graph_def [as 别名]
def __init__(self, event_writer, graph=None, graph_def=None):
    """Creates a `SummaryWriter` and an event file.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers constructed when you
    call one of the following functions: `add_summary()`, `add_session_log()`,
    `add_event()`, or `add_graph()`.

    If you pass a `Graph` to the constructor it is added to
    the event file. (This is equivalent to calling `add_graph()` later).

    TensorBoard will pick the graph from the file and display it graphically so
    you can interactively explore the graph you built. You will usually pass
    the graph from the session in which you launched it:

    ```python
    ...create a graph...
    # Launch the graph in a session.
    sess = tf.Session()
    # Create a summary writer, add the 'graph' to the event file.
    writer = tf.train.SummaryWriter(<some-directory>, sess.graph)
    ```


    Args:
      event_writer: An EventWriter. Implements add_event method.
      graph: A `Graph` object, such as `sess.graph`.
      graph_def: DEPRECATED: Use the `graph` argument instead.
    """
    self.event_writer = event_writer
    # For storing used tags for session.run() outputs.
    self._session_run_tags = {}
    if graph is not None or graph_def is not None:
      # Calling it with both graph and graph_def for backward compatibility.
      self.add_graph(graph=graph, graph_def=graph_def)
      # Also export the meta_graph_def in this case.
      # graph may itself be a graph_def due to positional arguments
      maybe_graph_as_def = (
          graph.as_graph_def(add_shapes=True) if isinstance(graph, ops.Graph)
          else graph)
      self.add_meta_graph(
          meta_graph.create_meta_graph_def(
              graph_def=graph_def or maybe_graph_as_def)) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:45,代码来源:writer.py


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