Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tutorials/image/cifar10/cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def _activation_summary(x):
# Remove 'tower_[0-9]/' from the name in case this is a multi-GPU training
# session. This helps the clarity of presentation on tensorboard.
tensor_name = re.sub('%s_[0-9]*/' % TOWER_NAME, '', x.op.name)
tf.contrib.deprecated.histogram_summary(tensor_name + '/activations', x)
tf.contrib.deprecated.scalar_summary(tensor_name + '/sparsity',
tf.summary.histogram(tensor_name + '/activations', x)
tf.summary.scalar(tensor_name + '/sparsity',
tf.nn.zero_fraction(x))


Expand Down Expand Up @@ -316,8 +316,8 @@ def _add_loss_summaries(total_loss):
for l in losses + [total_loss]:
# Name each loss as '(raw)' and name the moving average version of the loss
# as the original loss name.
tf.contrib.deprecated.scalar_summary(l.op.name + ' (raw)', l)
tf.contrib.deprecated.scalar_summary(l.op.name, loss_averages.average(l))
tf.summary.scalar(l.op.name + ' (raw)', l)
tf.summary.scalar(l.op.name, loss_averages.average(l))

return loss_averages_op

Expand Down Expand Up @@ -345,7 +345,7 @@ def train(total_loss, global_step):
decay_steps,
LEARNING_RATE_DECAY_FACTOR,
staircase=True)
tf.contrib.deprecated.scalar_summary('learning_rate', lr)
tf.summary.scalar('learning_rate', lr)

# Generate moving averages of all losses and associated summaries.
loss_averages_op = _add_loss_summaries(total_loss)
Expand All @@ -360,12 +360,12 @@ def train(total_loss, global_step):

# Add histograms for trainable variables.
for var in tf.trainable_variables():
tf.contrib.deprecated.histogram_summary(var.op.name, var)
tf.summary.histogram(var.op.name, var)

# Add histograms for gradients.
for grad, var in grads:
if grad is not None:
tf.contrib.deprecated.histogram_summary(var.op.name + '/gradients', grad)
tf.summary.histogram(var.op.name + '/gradients', grad)

# Track the moving averages of all trainable variables.
variable_averages = tf.train.ExponentialMovingAverage(
Expand Down
16 changes: 6 additions & 10 deletions tutorials/image/cifar10/cifar10_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,14 @@ class CIFAR10Record(object):
result.key, value = reader.read(filename_queue)

# Convert from a string to a vector of uint8 that is record_bytes long.
record_bytes = tf.decode_raw(value, tf.uint8)

value_bytes = tf.decode_raw(value, tf.uint8)
# The first bytes represent the label, which we convert from uint8->int32.
result.label = tf.cast(
tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32)
result.label = tf.cast(tf.slice(value_bytes, [0], [label_bytes]), tf.int32)
result.label.set_shape([1])

# The remaining bytes after the label represent the image, which we reshape
# from [depth * height * width] to [depth, height, width].
depth_major = tf.reshape(
tf.strided_slice(record_bytes, [label_bytes],
[label_bytes + image_bytes]),
depth_major = tf.reshape(tf.slice(value_bytes, [label_bytes], [image_bytes]),
[result.depth, result.height, result.width])
# Convert from [depth, height, width] to [height, width, depth].
result.uint8image = tf.transpose(depth_major, [1, 2, 0])
Expand Down Expand Up @@ -132,7 +129,7 @@ def _generate_image_and_label_batch(image, label, min_queue_examples,
capacity=min_queue_examples + 3 * batch_size)

# Display the training images in the visualizer.
tf.contrib.deprecated.image_summary('images', images)
tf.summary.image('images', images)

return images, tf.reshape(label_batch, [batch_size])

Expand Down Expand Up @@ -183,9 +180,8 @@ def distorted_inputs(data_dir, batch_size):
# Subtract off the mean and divide by the variance of the pixels.
float_image = tf.image.per_image_standardization(distorted_image)

# Set the shapes of tensors.
# Set the shape of the tensor.
float_image.set_shape([height, width, 3])
read_input.label.set_shape([1])

# Ensure that the random shuffling has good mixing properties.
min_fraction_of_examples_in_queue = 0.4
Expand Down