def test_v1_summary_tb_summary(self):
     tf_summary = summary_v1.scalar_pb("foo", 5.0)
     tb_summary = summary_pb2.Summary.FromString(
         tf_summary.SerializeToString())
     event = event_pb2.Event(step=1, wall_time=123.456, summary=tb_summary)
     run_proto = write_service_pb2.WriteScalarRequest.Run()
     self._populate_run_from_events(run_proto, [event])
     expected_run_proto = write_service_pb2.WriteScalarRequest.Run()
     foo_tag = expected_run_proto.tags.add()
     foo_tag.name = "foo/scalar_summary"
     foo_tag.metadata.display_name = "foo"
     foo_tag.metadata.plugin_data.plugin_name = "scalars"
     foo_tag.points.add(step=1,
                        wall_time=test_util.timestamp_pb(123456000000),
                        value=5.0)
     self.assertProtoEquals(run_proto, expected_run_proto)
Beispiel #2
0
import tensorflow as tf

from tensorboard.backend.event_processing import directory_watcher
from tensorboard.backend.event_processing import event_file_loader
from tensorboard.backend.event_processing import io_wrapper
from tensorboard.summary import v1 as summary_lib
from tensorboard.util import tensor_util

flags.DEFINE_string('benchmark_output_dir',
                    default=None,
                    help='Benchmark output directory.')

FLAGS = flags.FLAGS

_SCALAR_PLUGIN_NAME = summary_lib.scalar_pb(
    '', 0).value[0].metadata.plugin_data.plugin_name


def _make_events_generator(path):
    """Makes a generator yielding TensorBoard events from files in `path`."""
    return directory_watcher.DirectoryWatcher(
        path, event_file_loader.EventFileLoader,
        io_wrapper.IsSummaryEventsFile).Load()


def _is_scalar_value(value):
    if value.HasField('metadata') and value.metadata.HasField('plugin_data'):
        plugin_data = value.metadata.plugin_data
        return plugin_data.plugin_name == _SCALAR_PLUGIN_NAME

    return False