add tf version detection for new summary functions
@@ -543,7 +543,10 @@ class TensorBoard(Callback):
for layer in self.model.layers:
for weight in layer.weights:
+ if hasattr(tf, 'histogram_summary'):
tf.histogram_summary(weight.name, weight)
+ else:
+ tf.summary.histogram(weight.name, weight)
if self.write_images:
w_img = tf.squeeze(weight)
@@ -557,17 +560,26 @@ class TensorBoard(Callback):
w_img = tf.expand_dims(tf.expand_dims(w_img, 0), -1)
+ if hasattr(tf, 'image_summary'):
tf.image_summary(weight.name, w_img)
+ else:
+ tf.summary.image(weight.name, w_img)
if hasattr(layer, 'output'):
+ if hasattr(tf, 'histogram_summary'):
tf.histogram_summary('{}_out'.format(layer.name),
layer.output)
- if parse_version(tf.__version__) >= parse_version('0.12.0'):
- self.merged = tf.summary.merge_all()
else:
+ tf.summary.histogram('{}_out'.format(layer.name),
+ layer.output)
+
+ if hasattr(tf, 'merge_all_summaries'):
self.merged = tf.merge_all_summaries()
+ else:
+ self.merged = tf.summary.merge_all()
+
if self.write_graph:
- if parse_version(tf.__version__) >= parse_version('0.12.0'):
+ if hasattr(tf, 'summary') and hasattr(tf.summary, 'FileWriter'):
self.writer = tf.summary.FileWriter(self.log_dir,
self.sess.graph)
elif parse_version(tf.__version__) >= parse_version('0.8.0'):
@@ -577,7 +589,7 @@ class TensorBoard(Callback):
self.writer = tf.train.SummaryWriter(self.log_dir,
self.sess.graph_def)
else:
- if parse_version(tf.__version__) >= parse_version('0.12.0'):
+ if hasattr(tf, 'summary') and hasattr(tf.summary, 'FileWriter'):
self.writer = tf.summary.FileWriter(self.log_dir)
else:
self.writer = tf.train.SummaryWriter(self.log_dir)
