Let's say I have some timeseries data with shape (80,27)
which means 80 timesteps and 27 features. I want to train the following network in a way to predict each timestep separately and not the 80 timesteps together because in the prediction phase my input shape is (1,27)
each timestep t
until I reach t = 80
.
So I have to find a way to predict 80 samples-timesteps of (1,27)
without losing backpropagation through time when training.
Any suggestions?
def Model():
inputs = layers.Input(shape=(80,27))
x = layers.Conv1D(64,kernel_size=5,activation="relu",padding="same")(inputs)
x = layers.Bidirectional(layers.LSTM(256,return_sequences=True))(x)
x = layers.Bidirectional(layers.LSTM(256,return_sequences=True))(x)
x = layers.Bidirectional(layers.LSTM(256,return_sequences=True))(x)
x = layers.Bidirectional(layers.LSTM(128,return_sequences=True))(x)
x = layers.Bidirectional(layers.LSTM(128,return_sequences=True))(x)
x = layers.Bidirectional(layers.LSTM(128,return_sequences=True))(x)
x = layers.Dense(512,activation="selu")(x)
x = layers.Dense(256,activation="selu")(x)
x = layers.Dense(2)(x)
return keras.Model(inputs=inputs,outputs=x)
So there are two different questions to answer:
None
; that is, inputs = layers.Input(shape=(None, 27))
. The RNN will then be "unrolled" dynamically at training and testing time. (There might be some performance degradation but that is the price to pay.)