Negative dimension error while using keras Convolutional1D Layer

后端 未结 1 1053

I\'m trying to create a char cnn using Keras. That type of cnn requires you to use Convolutional1D layer. But all the ways I try to add them to my model, it giv

相关标签:
1条回答
  • 2021-01-20 05:58

    Your downsampling is too aggressive and the key argument here is max_len: when it's too small, the sequence becomes too short to perform either a convolution or a max-pooling. You set pool_size=3, hence it shrinks the sequence by a factor of 3 after each pooling (see the example below). I suggest you try pool_size=2.

    The minimal max_len that this network can handle is max_len=123. In this case x shape is transformed in the following way (according to conv_layers):

    (?, 123, 128)
    (?, 39, 256)
    (?, 11, 256)
    (?, 9, 256)
    (?, 7, 256)
    (?, 5, 256)
    

    Setting a smaller value, like max_len=120 causes x.shape=(?, 4, 256) before the last layer and this can't be performed.

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