AttributeError: module...ops‘ has no attribute ‘_TensorLike‘, ValueError: `updates` argument..eager
目的
keras和tensorflow結合使用很方便,然而坑點好多,好坑爹;
*問題是:
AttributeError: module ‘tensorflow.python.framework.ops’ has no attribute ‘_TensorLike’
原因在於keras匯入的和tensorflow.keras匯入的主次不同,結構有差異;
修改
*修改前
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.optimizers import RMSprop
- 修改後
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation
from tensorflow.keras.optimizers import RMSprop
中間經歷波折
一開始搜尋的以前 python3.6 + keras那些是用:
tensorflow_backend.py 的 line703
def is_tensor(x):
return isinstance(x, tf_ops._TensorLike) or tf_ops.is_dense_tensor_like(x)
返回型別修改為:
return isinstance(x, core_tf_types.Tensor) or tf_ops.is_dense_tensor_like(x)
* 結果改了一個bug引入另一個:
* ValueError: updates
argument is not supported during eager execution. 並且這個bug只有升級版本,然而我的已經是最新版本;糾結好久,一臉蒙圈。
* 最後恢復修改,重回搜尋最開始錯誤的解法。找到上述一個。
總結
問題修改多嘗試幾個,如果一個問題的修改引入另一個,那麼要麼接著改問題;要麼就返回原點,重新找答案。即,如果改了一個問題引入另一個,那麼也許一開始的解法就是錯誤的。
相關文章
- AttributeError: 'dict' object has no attribute 'has_key'ErrorObject
- AttributeError: 'module' object has no attribute 'lock'ErrorObject
- AttributeError: module ‘requests‘ has no attribute ‘_version_‘Error
- AttributeError: 'Settings' object has no attribute 'HBase'ErrorObject
- [轉]成功解決AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘?Error
- 問題解決:AttributeError: ‘NoneType‘ object has no attribute ‘append‘ErrorNoneObjectAPP
- Rasa init報錯:AttributeError: type object 'Callable' has no attribute '_abc_registry'ErrorObject
- Traceback (most recent call last): File "AttributeError: 'NoneType' object has no attribute 'group'ASTErrorNoneObject
- AttributeError: module ‘tensorflow._api.v1.nn.rnn_cell‘ has no attribute ‘InputProjectionWrapper‘ErrorAPIRNNProjectAPP
- 【Error】AttributeError: module ‘scipy.misc‘ has no attribute ‘logsumexp‘ 的解決辦法Error
- AttributeError: module‘ tensorflow_core._api.v2. train‘ has no attribute‘ AdamOptimizer‘ErrorAPIAI
- Process object has no attribute '_popen'Object
- ‘dict‘ object has no attribute ‘iteritems‘Object
- multiprocessing pool AttributeError: Can't get attribute 'func'Error
- 複雜網路中louvain演算法實現時報錯AttributeError: module ‘community‘ has no attribute ‘best_partition‘AI演算法ErrorUnity
- ‘FirewallD‘ object has no attribute ‘path‘ 、‘fw‘、is not registeredObject
- ValueError: output parameter for reduction operation logical_and has too many dimensions ?Error
- 1_使用face_recognition模組:錯誤AttributeError:'PngStream' object has no attribute 'chunk fcWp'(20190223)ErrorObject
- module ‘h5py‘ has no attribute ‘File‘H5
- 【坑】Tkinter ‘NoneType‘ object has no attribute ‘destroy‘NoneObject
- module ‘tensorflow‘ has no attribute ‘get_default_graph‘
- 解決pycharm問題:module 'pip' has no attribute 'main'PyCharmAI
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject
- Oracle RAC crsd日誌-0Resource ora!dbtest2!vip has incomplete attribute setOracle
- MySQL:sql_safe_updates生效點MySql
- Tensorboard: ValueError: Duplicate plugins for name projectorORBErrorPluginProject
- List of Oracle Database Patch Set Updates (PSU)OracleDatabase
- jQuery [attribute]jQuery
- Attribute Checks
- 理解Spring MVC Model Attribute和Session AttributeSpringMVCSession
- Powershell script to install Windows Updates (msu) from folderWindows
- Disable Dynamic DNS Updates in Windows 2008DNSWindows
- jQuery has()jQuery
- jQuery :has()jQuery
- oracle hasOracle
- dbfread報錯ValueError錯誤解決方法Error
- Django報錯ValueError: invalid literal for int() with base 10:DjangoError
- Python異常 ValueError的問題詳解PythonError