tensorflow之 AttributeError: module 'tensorflow' has no attribute 'sub'
学习官方给出的文档,发现报错
AttributeError: module 'tensorflow' has no attribute 'sub'
代码是这样写的:
#!/usr/bin/python3
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())
报错说的很清楚,tensorflow没有sub属性。
我使用的tensorflow是V1.9, 这个版本中,tensorflow的sub等属性都已经没有使用了。替换 sub 的是 subtract。替换后编译OK
还没有评论,来说两句吧...