Keras LSTM layers input shape

Viewed 1317

I am trying to feed a sequence with 20 featuresto an LSTM network as shown in the code. But I get an error that my Input0 is incompatible with LSTM input. Not sure how to change my layer structure to fit the data.

def build_model(features, aux1=None, aux2=None):
# create model
features[0] = np.asarray(features[0])
main_input = Input(shape=features[0].shape, dtype='float32', name='main_input')
main_out   = LSTM(40, activation='relu')
aux1_input = Input(shape=(len(aux1[0]),),   dtype='float32', name='aux1_input')
aux1_out   = Dense(len(aux1[0]))(aux1_input)
aux2_input = Input(shape=(len(aux2[0]),),   dtype='float32', name='aux2_input')
aux2_out   = Dense(len(aux2[0]))(aux2_input)
x = concatenate([aux1_out, main_out, aux2_out])
x = Dense(64, activation='relu')(x)
x = Dropout(0.5)(x)
output = Dense(1, activation='sigmoid', name='main_output')(x)
model = Model(inputs=[aux1_input, aux2_input, main_input], outputs= [output])
return model

Features variable is an array of shape (1456, 20) I have 1456 days and for each day I have 20 variables.

2 Answers
Related