本文整理汇总了Python中tensorboard.backend.event_processing.event_accumulator.SCALARS属性的典型用法代码示例。如果您正苦于以下问题:Python event_accumulator.SCALARS属性的具体用法?Python event_accumulator.SCALARS怎么用?Python event_accumulator.SCALARS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tensorboard.backend.event_processing.event_accumulator
的用法示例。
在下文中一共展示了event_accumulator.SCALARS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTags
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def testTags(self):
"""Tags should be found in EventAccumulator after adding some
events."""
gen = _EventGenerator(self)
gen.AddScalar("s1")
gen.AddScalar("s2")
gen.AddHistogram("hst1")
gen.AddHistogram("hst2")
gen.AddImage("im1")
gen.AddImage("im2")
gen.AddAudio("snd1")
gen.AddAudio("snd2")
acc = ea.EventAccumulator(gen)
acc.Reload()
self.assertTagsEqual(
acc.Tags(),
{
ea.IMAGES: ["im1", "im2"],
ea.AUDIO: ["snd1", "snd2"],
ea.SCALARS: ["s1", "s2"],
ea.HISTOGRAMS: ["hst1", "hst2"],
ea.COMPRESSED_HISTOGRAMS: ["hst1", "hst2"],
},
)
示例2: testReload
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def testReload(self):
"""EventAccumulator contains suitable tags after calling Reload."""
gen = _EventGenerator(self)
acc = ea.EventAccumulator(gen)
acc.Reload()
self.assertTagsEqual(acc.Tags(), {})
gen.AddScalar("s1")
gen.AddScalar("s2")
gen.AddHistogram("hst1")
gen.AddHistogram("hst2")
gen.AddImage("im1")
gen.AddImage("im2")
gen.AddAudio("snd1")
gen.AddAudio("snd2")
acc.Reload()
self.assertTagsEqual(
acc.Tags(),
{
ea.IMAGES: ["im1", "im2"],
ea.AUDIO: ["snd1", "snd2"],
ea.SCALARS: ["s1", "s2"],
ea.HISTOGRAMS: ["hst1", "hst2"],
ea.COMPRESSED_HISTOGRAMS: ["hst1", "hst2"],
},
)
示例3: testNonValueEvents
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def testNonValueEvents(self):
"""Non-value events in the generator don't cause early exits."""
gen = _EventGenerator(self)
acc = ea.EventAccumulator(gen)
gen.AddScalar("s1", wall_time=1, step=10, value=20)
gen.AddEvent(
event_pb2.Event(wall_time=2, step=20, file_version="nots2")
)
gen.AddScalar("s3", wall_time=3, step=100, value=1)
gen.AddHistogram("hst1")
gen.AddImage("im1")
gen.AddAudio("snd1")
acc.Reload()
self.assertTagsEqual(
acc.Tags(),
{
ea.IMAGES: ["im1"],
ea.AUDIO: ["snd1"],
ea.SCALARS: ["s1", "s3"],
ea.HISTOGRAMS: ["hst1"],
ea.COMPRESSED_HISTOGRAMS: ["hst1"],
},
)
示例4: _collect_metrics
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def _collect_metrics(self):
self._event_multiplexer.Reload()
subdir_data = {}
for i, subdir in enumerate(self._subdirs):
subdir_metrics = {}
accum = self._event_multiplexer.GetAccumulator(self._RUN_NAME % i)
for tag in accum.Tags()[event_accumulator.SCALARS]:
steps, vals = zip(*[
(event.step, event.value) for event in accum.Scalars(tag)])
subdir_metrics[tag] = (steps, vals)
subdir_data[subdir] = subdir_metrics
return subdir_data
示例5: assertTagsEqual
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def assertTagsEqual(self, actual, expected):
"""Utility method for checking the return value of the Tags() call.
It fills out the `expected` arg with the default (empty) values for every
tag type, so that the author needs only specify the non-empty values they
are interested in testing.
Args:
actual: The actual Accumulator tags response.
expected: The expected tags response (empty fields may be omitted)
"""
empty_tags = {
ea.IMAGES: [],
ea.AUDIO: [],
ea.SCALARS: [],
ea.HISTOGRAMS: [],
ea.COMPRESSED_HISTOGRAMS: [],
ea.GRAPH: False,
ea.META_GRAPH: False,
ea.RUN_METADATA: [],
ea.TENSORS: [],
}
# Verifies that there are no unexpected keys in the actual response.
# If this line fails, likely you added a new tag type, and need to update
# the empty_tags dictionary above.
self.assertItemsEqual(actual.keys(), empty_tags.keys())
for key in actual:
expected_value = expected.get(key, empty_tags[key])
if isinstance(expected_value, list):
self.assertItemsEqual(actual[key], expected_value)
else:
self.assertEqual(actual[key], expected_value)
示例6: testTFSummaryScalar
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def testTFSummaryScalar(self):
"""Verify processing of tf.summary.scalar."""
event_sink = _EventGenerator(self, zero_out_timestamps=True)
with test_util.FileWriterCache.get(self.get_temp_dir()) as writer:
writer.event_writer = event_sink
with self.test_session() as sess:
ipt = tf.compat.v1.placeholder(tf.float32)
tf.compat.v1.summary.scalar("scalar1", ipt)
tf.compat.v1.summary.scalar("scalar2", ipt * ipt)
merged = tf.compat.v1.summary.merge_all()
writer.add_graph(sess.graph)
for i in xrange(10):
summ = sess.run(merged, feed_dict={ipt: i})
writer.add_summary(summ, global_step=i)
accumulator = ea.EventAccumulator(event_sink)
accumulator.Reload()
seq1 = [
ea.ScalarEvent(wall_time=0, step=i, value=i) for i in xrange(10)
]
seq2 = [
ea.ScalarEvent(wall_time=0, step=i, value=i * i) for i in xrange(10)
]
self.assertTagsEqual(
accumulator.Tags(),
{
ea.SCALARS: ["scalar1", "scalar2"],
ea.GRAPH: True,
ea.META_GRAPH: False,
},
)
self.assertEqual(accumulator.Scalars("scalar1"), seq1)
self.assertEqual(accumulator.Scalars("scalar2"), seq2)
first_value = accumulator.Scalars("scalar1")[0].value
self.assertTrue(isinstance(first_value, float))
示例7: Scalars
# 需要导入模块: from tensorboard.backend.event_processing import event_accumulator [as 别名]
# 或者: from tensorboard.backend.event_processing.event_accumulator import SCALARS [as 别名]
def Scalars(self, tag_name):
return self._TagHelper(tag_name, event_accumulator.SCALARS)