繁体   English   中英

Tensorflow 2.3、Numpy 1.21.2 和 Python 3.8 错误

[英]Tensorflow 2.3, Numpy 1.21.2 and Python 3.8 Error

我看过多篇关于 Tensorflow 2.3 与 numpy 1.21.2 不兼容的帖子,解决方案是降级到 numpy 1.9 1.9 中的一些帖子(或某些帖子) 我已经使用conda install numpy=1.19尝试过,我再次尝试使用 1.18。 然后我通过调用 conda conda list确认 numpy package 是 1.19(或 1.18)。

但是,当我尝试执行此代码时,出现错误:

代码:

sentiment_wv_model = Sequential()
early_stopping = EarlyStopping()
sentiment_wv_model.add(embed_layer)
sentiment_wv_model.add(LSTM(128,input_shape=(1,500),return_sequences = True)) ###<<<<this line is where I get the error
sentiment_wv_model.add(Dense(100, activation = 'relu'))
sentiment_wv_model.add(Dropout(rate =0.25))

#sentiment_wv_model.add(Dropout(rate = 0.25))
sentiment_wv_model.add(Dense(32, activation = 'relu'))
sentiment_wv_model.add(Flatten())
sentiment_wv_model.add(Dense(1, activation='sigmoid'))

我得到的错误:

NotImplementedError: Cannot convert a symbolic Tensor (lstm_6/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

有任何想法吗?

我通过使用我需要的适当 package 版本的库创建单独的环境来解决这个问题。 然后,我编写了代码来实现我所需要的并保存了脚本。 然后,我调用了这些脚本并将所需的变量导入到我的 main.py 中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM