在學習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())
