20 lines
779 B
Python
20 lines
779 B
Python
|
import tensorflow as tf
|
||
|
|
||
|
|
||
|
class Logger(object):
|
||
|
def __init__(self, log_dir):
|
||
|
"""Create a summary writer logging to log_dir."""
|
||
|
self.writer = tf.summary.create_file_writer(log_dir)
|
||
|
|
||
|
def scalar_summary(self, tag, value, step):
|
||
|
with self.writer.as_default():
|
||
|
tf.summary.scalar(tag, value, step=step)
|
||
|
self.writer.flush()
|
||
|
def list_of_scalars_summary(self, tag_value_pairs, step):
|
||
|
with self.writer.as_default():
|
||
|
for tag, value in tag_value_pairs:
|
||
|
tf.summary.scalar(tag, value, step=step)
|
||
|
self.writer.flush()
|
||
|
# summary = tf.Summary(value=[tf.Summary.Value(tag=tag, simple_value=value) for tag, value in tag_value_pairs])
|
||
|
# self.writer.add_summary(summary, step)
|