简体   繁体   中英

Tensorflow 2.3, Numpy 1.21.2 and Python 3.8 Error

I have seen multiple posts about Tensorflow 2.3 not being compatible with numpy 1.21.2 and the solution being to downgrade to numpy 1.19 (or in some posts 1.18). I have tried this using conda install numpy=1.19 and I tried again with 1.18. Then I confirm the numpy package is 1.19 (or 1.18) by calling conda list .

However, when I try to execute this code, I get an error:

Code:

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'))

The error I get:

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

Any ideas?

I resolved this by creating separate environments with the appropriate package versions of the libraries I needed. Then, I wrote the code to achieve what I needed and saved the scripts. Then, I called those scripts and imported the needed variables into my main.py.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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