Skip to content

Commit

Permalink
Change Python print to be compatible with Python3 (tensorflow#8470)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryshao authored and jhseu committed Mar 16, 2017
1 parent 3212251 commit 17cb53e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tensorflow/docs_src/get_started/mnist/mechanics.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ training.

```python
if step % 100 == 0:
print 'Step %d: loss = %.2f (%.3f sec)' % (step, loss_value, duration)
print('Step %d: loss = %.2f (%.3f sec)' % (step, loss_value, duration))
```

#### Visualize the Status
Expand Down Expand Up @@ -421,19 +421,19 @@ the training and test datasets. The `do_eval()` function is called thrice, for
the training, validation, and test datasets.

```python
print 'Training Data Eval:'
print('Training Data Eval:')
do_eval(sess,
eval_correct,
images_placeholder,
labels_placeholder,
data_sets.train)
print 'Validation Data Eval:'
print('Validation Data Eval:')
do_eval(sess,
eval_correct,
images_placeholder,
labels_placeholder,
data_sets.validation)
print 'Test Data Eval:'
print('Test Data Eval:')
do_eval(sess,
eval_correct,
images_placeholder,
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/docs_src/programmers_guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ two following snippets of code are equivalent:
# Using `Session.run()`.
sess = tf.Session()
c = tf.constant(5.0)
print sess.run(c)
print(sess.run(c))

# Using `Tensor.eval()`.
c = tf.constant(5.0)
with tf.Session():
print c.eval()
print(c.eval())
```

In the second example, the session acts as a
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/docs_src/tutorials/linear.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ results = e.evaluate(input_fn=input_fn_test, steps=1)

# Print the stats for the evaluation.
for key in sorted(results):
print "%s: %s" % (key, results[key])
print("%s: %s" % (key, results[key]))
```

### Wide and deep learning
Expand Down
10 changes: 5 additions & 5 deletions tensorflow/docs_src/tutorials/using_gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ c = tf.matmul(a, b)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print sess.run(c)
print(sess.run(c))
```

You should see the following output:
Expand Down Expand Up @@ -61,7 +61,7 @@ with tf.device('/cpu:0'):
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print sess.run(c)
print(sess.run(c))
```

You will see that now `a` and `b` are assigned to `cpu:0`.
Expand Down Expand Up @@ -131,7 +131,7 @@ with tf.device('/gpu:2'):
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print sess.run(c)
print(sess.run(c))
```

If the device you have specified does not exist, you will get
Expand Down Expand Up @@ -160,7 +160,7 @@ with tf.device('/gpu:2'):
sess = tf.Session(config=tf.ConfigProto(
allow_soft_placement=True, log_device_placement=True))
# Runs the op.
print sess.run(c)
print(sess.run(c))
```

## Using multiple GPUs
Expand All @@ -182,7 +182,7 @@ with tf.device('/cpu:0'):
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print sess.run(sum)
print(sess.run(sum))
```

You will see the following output.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/docs_src/tutorials/wide.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ the labels of the holdout data:
```python
results = m.evaluate(input_fn=eval_input_fn, steps=1)
for key in sorted(results):
print "%s: %s" % (key, results[key])
print("%s: %s" % (key, results[key]))
```
The first line of the output should be something like `accuracy: 0.83557522`,
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/docs_src/tutorials/wide_and_deep.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ After reading in the data, you can train and evaluate the model:
m.fit(input_fn=train_input_fn, steps=200)
results = m.evaluate(input_fn=eval_input_fn, steps=1)
for key in sorted(results):
print "%s: %s" % (key, results[key])
print("%s: %s" % (key, results[key]))
```
The first line of the output should be something like `accuracy: 0.84429705`. We
Expand Down

0 comments on commit 17cb53e

Please sign in to comment.