Fit keras model without y values

Viewed 753

I'm building a model using Keras to predict a 2 week series of atmospheric pressure values. Below is the model structure I'm using:

self.model = Sequential()
self.model.add(CuDNNLSTM(256, return_sequences=False, input_shape=(None, 2)))
self.model.add(RepeatVector(336))  # 336 corresponds to 2 weeks of hourly values (24 x 14)
self.model.add(CuDNNLSTM(128, return_sequences=True))
self.model.add(TimeDistributed(Dense(2)))

(NOTE: The CuDNNLSTM layer does the same as the LSTM layer in Keras, but it runs much faster on Nvidia GPUs)

For training the model, x has the form [n_samples, n_time_steps, n_features], where n_samples is the number of training series (there is one for each weather station), n_time_steps is the number of hourly data points per series and n_features is the number of features per time step (in this case, the first feature is the atmospheric pressure, and the second feature is either 0 or 1 depending on the weather condition). All of the training data is normalised between -1 and 1.

y has the same structure as x, but it contains hourly data for the 2 weeks following the 2 weeks of hourly data in x.

The model trains and achieves a validation loss of 0.28115. When I make predictions using the model on unseen data, the predictions follow the correct pattern of rising and falling throughout the day, however, they do not reach the correct peaks and lows, since each series is slightly different. To combat this, I would normally fit the general model once on the specific series before predicting to adjust the weights a bit to that specific series. The problem is, I don't have enough data to generate x and y to feed into model.fit(), as y requires 336 time steps.

Is there a way to fit a model without specifying y? I built a model that makes one hourly prediction at a time in a loop instead of all at once, which gets around the issue. However, I would like to be able to predict the whole 2 week series at once. Is there a better way to go about this?

Also, is it possible to have the model only predict the atmospheric pressure feature and not the other binary one? Would this even impact performance? I would normally do this by adding a Dense(1) layer at the end of the Sequential() model like in the example below, but I don't know how to do it when using the RepeatVector() layer further up. (The RepeatVector() layer is used to predict multiple timesteps at once).

self.model = Sequential()
self.model.add(CuDNNLSTM(256, return_sequences=True, input_shape=(None, 2)))
self.model.add(CuDNNLSTM(128, return_sequences=False))
self.model.add(Dense(1))
0 Answers
Related