'tensorflow' has no attribute 'sub'
在学习tensorflow的时候,照到官方的例子做,发现了一个
Traceback (most recent call last): File "interactive.py", line 10, in <module> sub = tf.sub(x,a) AttributeError: module 'tensorflow' has no attribute 'sub'
一猜,我就估计是函数换名字了,果然,换成了subtract 这样就坑过了
# -*- coding: utf-8 -*- 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.subtract(x,a) print(sub.eval())