-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtensorboardwriter.py
31 lines (21 loc) · 1017 Bytes
/
tensorboardwriter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import tensorflow as tf
def tensorboard_write_metrics(summary_writer, metric, epoch):
with summary_writer.as_default():
tf.summary.scalar(metric.name, metric.result(), step=epoch)
summary_writer.flush()
def tensorboard_write_prf(summary_writer, name, value, epoch):
with summary_writer.as_default():
tf.summary.scalar(name, value, step=epoch)
summary_writer.flush()
def tensorboard_write_weights(summary_writer, model, epoch):
with summary_writer.as_default():
for weight in model.trainable_variables:
tf.summary.histogram(weight.name, data=weight.numpy().tolist(), step=epoch)
summary_writer.flush()
def tensorboard_write_grads(summary_writer, model, grads, epoch):
with summary_writer.as_default():
for weight, grad in zip(model.trainable_variables, grads):
tf.summary.histogram(weight.name, data=grad, step=epoch)
summary_writer.flush()
def tensorboard_write_cm(summary_writer, img, epoch):
pass