tensorflow version 2.3.1 numpy version 1.20
below the code
# define model model = Sequential() model.add(LSTM(50, activation='relu', input_shape=(n_steps, n_features))) model.add(Dense(1)) model.compile(optimizer='adam', loss='mse')
NotImplementedError: Cannot convert a symbolic Tensor (lstm_2/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
it seems to me a crazy error!
Similar issue, with
on Windows 7.
Solved by modifying
def __array__(self): raise NotImplementedError(
at line #845~846 with
def __array__(self): raise TypeError(
Tensorflow 2.5 update:
tensorflow and tensorflow-gpu 2.5 packages still includes numpy-1.19.5 as a dependency.
The error referenced in this post will be reproduced if tensorflow 2.5 installation is mixed with numpy>1.19.5
tensorflow-2.5, numpy-1.19.5 are compatible with python-3.9
I faced this issue with M1 chip. Here is the how I fixed:
conda create create --name tf conda activate tf conda install numpy ~=1.18.5 pip install tensorflow-macos
and voila you are ready to go !
I had the same issue with
tensorflow 2.5.0 and
numpy 1.21.2. There were suggestions here to make changes in
array_ops.py file but this didn't work for me. Another answer in the same page with following steps worked.
pip uninstall tensorflow pip install tensorflow pip uninstall numpy pip install numpy
Basically these steps don't downgrade numpy but either upgrades or keeps it at the same level. Above steps upgraded
tensorflow 2.7.0 and
numpy 1.21.4 and my code ran without any issues.