Does 'tf.assign' return its argument?

Viewed 340

The Tensorflow documentation says that tf.assign(ref, ...) returns ref, but it appears instead (not surprisingly) to return a Tensor (attached to the assign op):

import tensorflow as tf
sess = tf.InteractiveSession()

Q = tf.Variable(tf.constant(range(1, 12)))
sess.run(tf.global_variables_initializer())
qop = tf.assign(Q, tf.zeros(Q.shape, tf.int32))#.eval()

print(Q.eval())
print(qop.eval())
print(Q.eval())

produces

[ 1  2  3  4  5  6  7  8  9 10 11]
[0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0]

demonstrating that the argument Q and what's returned qop behave differently (and that Q is unchanged until qop is executed).

Is the return value of tf.assign described correctly in the documentation?

1 Answers
Related