I'm trying to create a small Bidirectional recurrent NN. The model itself compiles without error, but when trying to fit the model I get the error stating I should compile first. Please see the code snippet below:
# fourth recurrent model, bidirectional
bidirectional_recurrent = Sequential()
bidirectional_recurrent.add(Bidirectional(GRU(32, input_shape=(int(lookback/steps), data_scaled.shape[-1]))))
bidirectional_recurrent.add(Dense(1))
bidirectional_recurrent.compile(optimizer='rmsprop', loss='mae')
bidirectional_recurrent_history = bidirectional_recurrent.fit_generator(train_gen, steps_per_epoch=500, epochs=40,
validation_data=val_gen, validation_steps=val_steps)
RuntimeError: You must compile your model before using it.
I've used the same setup to train unidirectional RNN's which worked fine. Any tips to help solve the run-time error are appreciated. (restarting the kernel did not help)
Maybe I did not instantiate 'Bidirectional' correctly?
Please note: This question is different from Do I need to compile before 'X' type of questions
Note2: R examples of the same code can be found here