keras lstm/anaconda问题,无法使用python 3.8的conda升级到2.6.0
我很疯狂地尝试解决这个问题< /a>
NotImplementedError: Cannot convert a symbolic Tensor (LSTM-4/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
我从Windows 10 PC上的Anaconda进行全新安装开始:
C:\WINDOWS\system32>conda info
active environment : base
active env location : C:\Anaconda3
shell level : 1
user config file : C:\Users\Administrator\.condarc
populated config files :
conda version : 4.12.0
conda-build version : 3.21.4
python version : 3.8.8.final.0
virtual packages : __win=0=0
__archspec=1=x86_64
base environment : C:\Anaconda3 (writable)
conda av data dir : C:\Anaconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Anaconda3\pkgs
C:\Users\Administrator\.conda\pkgs
C:\Users\Administrator\AppData\Local\conda\conda\pkgs
envs directories : C:\Anaconda3\envs
C:\Users\Administrator\.conda\envs
C:\Users\Administrator\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.12.0 requests/2.25.1 CPython/3.8.8 Windows/10 Windows/10.0.19041
administrator : True
netrc file : None
offline mode : False
然后我安装了TensorFlow软件包,
conda install tensorflow
然后尝试按照
model = Sequential()
model.add(LSTM(50, input_shape=(train_X.shape[1], train_X.shape[2])))
model.add(Dense(1))
model.compile(loss='mae', optimizer='adam')
生成错误的行(生成错误的实际行是LSTM层的添加)。
然后,我尝试升级到TF 2.6.0,但是,给出以下更新命令
conda install -c conda-forge tensorflow=2.6.0
导致无法解决的冲突噩梦(几个小时后,冲突输出超过8 klines,并溢出了我的壳缓冲区)。
我有两个问题:
- 如何解决问题,这意味着我需要Python 3.8和支持LSTM网络的TensorFlow?我尝试升级到2.6.0的计划是否有意义?
- Anaconda稳定释放的可能性如何才能用破损的张量包装发货?可能是过时的榜样?在这种情况下,有人可以建议正确的语法吗?
真挚地,
I am getting crazy trying to solve this problem
NotImplementedError: Cannot convert a symbolic Tensor (LSTM-4/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
I started with a fresh installation of Anaconda on my Windows 10 PC:
C:\WINDOWS\system32>conda info
active environment : base
active env location : C:\Anaconda3
shell level : 1
user config file : C:\Users\Administrator\.condarc
populated config files :
conda version : 4.12.0
conda-build version : 3.21.4
python version : 3.8.8.final.0
virtual packages : __win=0=0
__archspec=1=x86_64
base environment : C:\Anaconda3 (writable)
conda av data dir : C:\Anaconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Anaconda3\pkgs
C:\Users\Administrator\.conda\pkgs
C:\Users\Administrator\AppData\Local\conda\conda\pkgs
envs directories : C:\Anaconda3\envs
C:\Users\Administrator\.conda\envs
C:\Users\Administrator\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.12.0 requests/2.25.1 CPython/3.8.8 Windows/10 Windows/10.0.19041
administrator : True
netrc file : None
offline mode : False
Then I installed the tensorflow package with
conda install tensorflow
Then I tried to create a model following this example, in particular lines
model = Sequential()
model.add(LSTM(50, input_shape=(train_X.shape[1], train_X.shape[2])))
model.add(Dense(1))
model.compile(loss='mae', optimizer='adam')
Which generates the error (the actual line generating the error is the addition of the LSTM layer).
I then tried to upgrade to TF 2.6.0, however, giving the following update command
conda install -c conda-forge tensorflow=2.6.0
leads to a nightmare of conflicts that cannot be resolved (several hours later the conflict output is past 8 klines and overflows my shell buffer).
I have two questions:
- How can I resolve the problem, meaning I need python 3.8 and tensorflow supporting LSTM networks? Does my plan to try upgrading to 2.6.0 make sense?
- How it is possible that a stable release from Anaconda does ship with a broken tensorflow package? Could be the example being outdated? In this case can somebody suggest the right syntax?
Sincerely,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TensorFlow支持TensorFlow v2.2.0的LSTM。另外,请确保安装KERAS 2.3以避免错误。
使用以下命令检查KERAS版本。
如果您想升级TensorFlow,
请使用以下命令卸载TensorFlow。
请创建一个conda环境,然后使用PIP命令安装TensorFlow。建议在conda上使用PIP,因为TensorFlow仅是正式的NBSP;发布给PYPI。
TensorFlow需要最近版本的PIP,因此请升级PIP安装,以确保您正在运行最新版本。
然后,使用PIP安装TensorFlow。
请参阅此文档以获取更多信息。谢谢你!
Tensorflow supports LSTM from TensorFlow v2.2.0. Also make sure that keras 2.3 is installed to avoid the error.
Check the keras version with the following command.
If you wish to upgrade tensorflow,
Uninstall tensorflow with the following command.
please create a conda environment and then install tensorflow with the pip command. It is recommended to use pip over conda since TensorFlow is only officially released to PyPI.
TensorFlow requires a recent version of pip, so upgrade your pip installation to be sure you're running the latest version.
Then, install TensorFlow with pip.
Please refer to this document for more information. Thank you!