我希望有人回答下面的错误代码,我正在研究监督ML,我得到了一个错误。
我的库详细信息(由于我将上述两个包降级为上面提到的当前包详细信息,许多开发人员都说要降级版本,它将工作,但在我的情况下,它不工作):
- Numpy:1.18.5当前版本(早期版本为1.20.3)
- tensorflow 量:2.5.0当前版本(早期版本为2.4.1)
- Python语言:3.8.8
- 角化系数:2.4.3
下面是代码:
# Defining the LSTM model to be fit
model = Sequential()
model.add(LSTM(85, input_shape=(1, 53)))
model.add(Dense(1))
model.compile(loss='mae', optimizer='adam')
# Fitting the model
history = model.fit(train_X, train_y, epochs=70, batch_size=175, validation_data=(test_X, test_y), verbose=2, shuffle=False)
# Plotting the training progression
pyplot.plot(history.history['loss'], label='train')
pyplot.plot(history.history['val_loss'], label='test')
pyplot.legend()
pyplot.show()
和错误:
NotImplementedError Traceback (most recent call last)
<ipython-input-10-251aaaf9021e> in <module>
1 # Defining the LSTM model to be fit
2 model = Sequential()
----> 3 model.add(LSTM(85, input_shape=(train_X.shape[1], train_X.shape[2])))
4 model.add(Dense(1))
5 model.compile(loss='mae', optimizer='adam')
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
1条答案
按热度按时间wz3gfoph1#
在添加依赖于层input_shape的LSTM模型时得到的解决方案是不合适的,因此将形状更改为