AttributeError: module 'tensorflow' has no attribute 'sub'
生活随笔
收集整理的這篇文章主要介紹了
AttributeError: module 'tensorflow' has no attribute 'sub'
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
官方的例子:運(yùn)行之后出現(xiàn)以下錯(cuò)誤
# 進(jìn)入一個(gè)交互式 TensorFlow 會(huì)話(huà). import tensorflow as tf sess = tf.InteractiveSession()x = tf.Variable([1.0, 2.0]) a = tf.constant([3.0, 3.0])# 使用初始化器 initializer op 的 run() 方法初始化 'x' x.initializer.run()# 增加一個(gè)減法 sub op, 從 'x' 減去 'a'. 運(yùn)行減法 op, 輸出結(jié)果 sub = tf.sub(x, a) print sub.eval() # ==> [-2. -1.]?
Traceback (most recent call last):File "C:\Users\lzm\Desktop\ten-1.py", line 10, in <module>sub = tf.sub(x, a) AttributeError: module 'tensorflow' has no attribute 'sub'?
出現(xiàn)這個(gè)問(wèn)題是因?yàn)閟ub函數(shù)換名字了,換成了subtract?
# 進(jìn)入一個(gè)交互式 TensorFlow 會(huì)話(huà). import tensorflow as tf sess = tf.InteractiveSession()x = tf.Variable([1.0, 2.0]) a = tf.constant([3.0, 3.0])# 使用初始化器 initializer op 的 run() 方法初始化 'x' x.initializer.run()# 增加一個(gè)減法 sub op, 從 'x' 減去 'a'. 運(yùn)行減法 op, 輸出結(jié)果 sub = tf.subtract(x, a) print sub.eval() # ==> [-2. -1.]?
轉(zhuǎn)載于:https://www.cnblogs.com/QW-lzm/p/10499013.html
與50位技術(shù)專(zhuān)家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的AttributeError: module 'tensorflow' has no attribute 'sub'的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: bootstrap思考一
- 下一篇: Struts第一个案例搭建