I run the following code in tensorflow 2.2
a = tf.constant([2.0, 3.0, 4.0])
b = tf.Variable([4.0, 3.0, 5.0])
c = a * b
Value of b
is:
<tf.Variable 'Variable:0' shape=(3,) dtype=float32, numpy=array([4., 3., 5.], dtype=float32)>
Value of c
is:
<tf.Tensor: shape=(3,), dtype=float32, numpy=array([ 8., 9., 20.], dtype=float32)>
if I update the variable b now
b.assign( [ 1.0, 1.0 , 1.0] )
# b is now <tf.Variable 'Variable:0' shape=(3,) dtype=float32, numpy=array([1., 1., 1.], dtype=float32)>
But when i print the value of c
, which i expect it should have changed since b
has changed, but c
does not change
# c is still <tf.Tensor: shape=(3,), dtype=float32, numpy=array([ 8., 9., 20.], dtype=float32)>
My test is running in eager mode. tf.executing_eagerly() = True now
What is the reason behind?