1

I am unable to build an LSTM network because everytime I try to create it using the code below I get the following error: NotImplementedError: Cannot convert a symbolic Tensor (lstm_15/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

My code is as follows:

rnn_model = Sequential()
rnn_model.add(LSTM(16,input_shape=(20,1)))
rnn_model.add(Dense(10))
rnn_model.add(Dense(1))

What is going wrong exactly?

NoobC0der
  • 75
  • 2
  • 8
  • 3
    Add the full code to reproduce your error, your snippet is perfectly valid. You can look at this guide: [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Lescurel Feb 11 '21 at 10:41
  • Does this answer your question? [NotImplementedError: Cannot convert a symbolic Tensor (lstm\_2/strided\_slice:0) to a numpy array. T](https://stackoverflow.com/questions/66207609/notimplementederror-cannot-convert-a-symbolic-tensor-lstm-2-strided-slice0-t) – Hanna Jul 15 '21 at 19:54

1 Answers1

1

It's because you are using a non-compatible version of NumPy. If you are using TensorFlow 2.4.1 you need to use the following version of Numpy:

pip install -U numpy==1.19.2
Alex
  • 19
  • 2