fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
17.95k stars 8.48k forks source link

10.2.5 A first recurrent baseline #198

Open hodfa840 opened 2 years ago

hodfa840 commented 2 years ago

Hello, I am trying to run the cell LSTM for weather prediction in time series: notebook 10

inputs = keras.Input(shape=(sequence_length, raw_data.shape[-1])) x = layers.LSTM(16)(inputs) outputs = layers.Dense(1)(x) model = keras.Model(inputs, outputs)

callbacks = [ keras.callbacks.ModelCheckpoint("jena_lstm.keras", save_best_only=True) ] model.compile(optimizer="rmsprop", loss="mse", metrics=["mae"]) history = model.fit(train_dataset, epochs=10, validation_data=val_dataset, callbacks=callbacks)

model = keras.models.load_model("jena_lstm.keras") print(f"Test MAE: {model.evaluate(test_dataset)[1]:.2f}")

I get the following error:

_NotImplementedError: Cannot convert a symbolic Tensor (lstm/stridedslice: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

I use tensorflow 2.4.1