aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/examples/image_retraining
diff options
context:
space:
mode:
authorGravatar Dan Mané <danmane@google.com>2016-10-20 11:26:43 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-10-20 12:35:29 -0700
commit8532897352ada1d8ecd3ca1dd17aaa869a42d4b8 (patch)
treedb2d24ac8d56d6ad4c135927e196fe5521cf3ec0 /tensorflow/examples/image_retraining
parent447dae3acf2cce61664d703555c7317da40fa2d4 (diff)
Shift tensorflow/examples over to the new summary ops.
This is a fairly minimal change, some functions have been cleaned up slightly because the new summary ops dont need manual namespacing. Behavior is approximately identical. Change: 136745220
Diffstat (limited to 'tensorflow/examples/image_retraining')
-rw-r--r--tensorflow/examples/image_retraining/retrain.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/tensorflow/examples/image_retraining/retrain.py b/tensorflow/examples/image_retraining/retrain.py
index d52a23fd15..4f06cb8add 100644
--- a/tensorflow/examples/image_retraining/retrain.py
+++ b/tensorflow/examples/image_retraining/retrain.py
@@ -647,17 +647,17 @@ def add_input_distortions(flip_left_right, random_crop, random_scale,
return jpeg_data, distort_result
-def variable_summaries(var, name):
+def variable_summaries(var):
"""Attach a lot of summaries to a Tensor (for TensorBoard visualization)."""
with tf.name_scope('summaries'):
mean = tf.reduce_mean(var)
- tf.scalar_summary('mean/' + name, mean)
+ tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
- tf.scalar_summary('stddev/' + name, stddev)
- tf.scalar_summary('max/' + name, tf.reduce_max(var))
- tf.scalar_summary('min/' + name, tf.reduce_min(var))
- tf.histogram_summary(name, var)
+ tf.summary.scalar('stddev', stddev)
+ tf.summary.scalar('max', tf.reduce_max(var))
+ tf.summary.scalar('min', tf.reduce_min(var))
+ tf.summary.histogram('histogram', var)
def add_final_training_ops(class_count, final_tensor_name, bottleneck_tensor):
@@ -695,23 +695,23 @@ def add_final_training_ops(class_count, final_tensor_name, bottleneck_tensor):
with tf.name_scope(layer_name):
with tf.name_scope('weights'):
layer_weights = tf.Variable(tf.truncated_normal([BOTTLENECK_TENSOR_SIZE, class_count], stddev=0.001), name='final_weights')
- variable_summaries(layer_weights, layer_name + '/weights')
+ variable_summaries(layer_weights)
with tf.name_scope('biases'):
layer_biases = tf.Variable(tf.zeros([class_count]), name='final_biases')
- variable_summaries(layer_biases, layer_name + '/biases')
+ variable_summaries(layer_biases)
with tf.name_scope('Wx_plus_b'):
logits = tf.matmul(bottleneck_input, layer_weights) + layer_biases
- tf.histogram_summary(layer_name + '/pre_activations', logits)
+ tf.summary.histogram('pre_activations', logits)
final_tensor = tf.nn.softmax(logits, name=final_tensor_name)
- tf.histogram_summary(final_tensor_name + '/activations', final_tensor)
+ tf.summary.histogram('activations', final_tensor)
with tf.name_scope('cross_entropy'):
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
logits, ground_truth_input)
with tf.name_scope('total'):
cross_entropy_mean = tf.reduce_mean(cross_entropy)
- tf.scalar_summary('cross entropy', cross_entropy_mean)
+ tf.summary.scalar('cross_entropy', cross_entropy_mean)
with tf.name_scope('train'):
train_step = tf.train.GradientDescentOptimizer(FLAGS.learning_rate).minimize(
@@ -738,7 +738,7 @@ def add_evaluation_step(result_tensor, ground_truth_tensor):
tf.argmax(ground_truth_tensor, 1))
with tf.name_scope('accuracy'):
evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
- tf.scalar_summary('accuracy', evaluation_step)
+ tf.summary.scalar('accuracy', evaluation_step)
return evaluation_step
@@ -792,7 +792,7 @@ def main(_):
evaluation_step = add_evaluation_step(final_tensor, ground_truth_input)
# Merge all the summaries and write them out to /tmp/retrain_logs (by default)
- merged = tf.merge_all_summaries()
+ merged = tf.summary.merge_all()
train_writer = tf.train.SummaryWriter(FLAGS.summaries_dir + '/train',
sess.graph)
validation_writer = tf.train.SummaryWriter(FLAGS.summaries_dir + '/validation')