Input 0 is incompatible with layer gru_13: expected ndim=3, found ndim=2

后端 未结 1 1225
有刺的猬
有刺的猬 2021-01-21 17:52

I want to use 3CNN with 3GRU layers. Here is the architecture:

layer_a = Input(shape         


        
相关标签:
1条回答
  • 2021-01-21 18:08

    GRU layers need the following dimension (batch_size, seq_len, dim_per_seq) also it returns (batch_siz, number_of_neurons) so in order to put 2 GRU after each other, the first GRU layer need to set the parameter return_sequences=True.

    Also, when building keras models it's always a good idea to use model.summary()(just build part of the model before the erroe appears) to debug. Often the problem lies in an unexpected shape.

    Your architecture is not suited for using GRU layers at all. First you can't flatten the tensors because this will destroy your sequence like structure. This will make concatenating the layers impossible. You could conv and pool your tree layers layer_t, layer_tt and layer_ttt to the same second dimension (should be bigger then 1). This way you could concatenate the last dimension and get a tensor with a sequence like shape to put into a gru layer.

    0 讨论(0)
提交回复
热议问题