Keras Bidirectional “RuntimeError: You must compile your model before using it.” after compilation completed

后端 未结 1 440
误落风尘
误落风尘 2021-01-19 18:28

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

相关标签:
1条回答
  • 2021-01-19 19:22

    Found it,
    When using Bidirectional, it should be treated as a layer, shifting the input_shape to be contained in Bidirectional() instead of in the GRU() object solved the problem

    so

    bidirectional_recurrent.add(Bidirectional(GRU(32, input_shape=(int(lookback/steps),
                                data_scaled.shape[-1]))))
    

    becomes

    bidirectional_recurrent.add(Bidirectional(GRU(32), input_shape=(int(lookback/steps),
                                data_scaled.shape[-1])))
    
    0 讨论(0)
提交回复
热议问题