AttributeError: module 'tensorflow' has no attribute 'sub'
生活随笔
收集整理的這篇文章主要介紹了
AttributeError: module 'tensorflow' has no attribute 'sub'
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
官方的例子:運行之后出現以下錯誤
# 進入一個交互式 TensorFlow 會話. 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()# 增加一個減法 sub op, 從 'x' 減去 'a'. 運行減法 op, 輸出結果 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'?
出現這個問題是因為sub函數換名字了,換成了subtract?
# 進入一個交互式 TensorFlow 會話. 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()# 增加一個減法 sub op, 從 'x' 減去 'a'. 運行減法 op, 輸出結果 sub = tf.subtract(x, a) print sub.eval() # ==> [-2. -1.]?
轉載于:https://www.cnblogs.com/QW-lzm/p/10499013.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的AttributeError: module 'tensorflow' has no attribute 'sub'的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: bootstrap思考一
- 下一篇: Struts第一个案例搭建