代码:
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])
x.initializer.run()
sub = tf.sub(x, a)
print (sub.eval())
报错:
AttributeError: module 'tensorflow' has no attribute 'sub'
解决办法:
sub = tf.subtract(x, a)