Skip to content

Commit

Permalink
Changed how the input shape is set in the LSTMForecaster following ne…
Browse files Browse the repository at this point in the history
…wer Kears recommendations.
  • Loading branch information
sarusso committed Nov 3, 2024
1 parent 6eaebe6 commit 3c55450
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions timeseria/models/forecasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,13 +1026,16 @@ def root_mean_squared_error(y_true, y_pred):
features_per_window_item = len(window_features_matrix[0][0])
output_dimension = len(target_values_vector[0])

# Set the input shape
input_shape=(self.data['window'] + 1 if with_context else self.data['window'], features_per_window_item)

# Create the default model architecture if not already set (either because we are updating or because it was provided in the init)
if not self.keras_model:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import LSTM
from tensorflow.keras.layers import Input, LSTM, Dense
self.keras_model = Sequential()
self.keras_model.add(LSTM(self.data['neurons'], input_shape=(self.data['window'] + 1 if with_context else self.data['window'], features_per_window_item)))
self.keras_model.add(Input(input_shape))
self.keras_model.add(LSTM(self.data['neurons'], ))
self.keras_model.add(Dense(output_dimension))
self.keras_model.compile(loss=loss, optimizer='adam')

Expand Down

0 comments on commit 3c55450

Please sign in to comment.