Ch 02: Concept 04

Session logging

Define an op on a tensor. Here's an example:


In [1]:
import tensorflow as tf

x = tf.constant([[1, 2]])
neg_op = tf.negative(x)

Now let's use a session with a special argument passed in.


In [3]:
with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as sess:
    result = sess.run(neg_op)
    print(result)


[[-1 -2]]

Try this from a terminal. Jupyter notebooks won't show the logging info.