[英]Multiple Conv1D Layers: Negative dimension size caused by subtracting 8 from 1 for 'conv1d_2/convolution/Conv2D
I'm still quite novice with regard to convolutional networks. 关于卷积网络,我仍然相当新手。 I'm trying to implement multiple Conv1D layers in Keras.
我正在尝试在Keras中实现多个Conv1D层。 Unfortunately, after the very first layer, any subsequent layers throw the following error:
不幸的是,在第一层之后,任何后续层都会抛出以下错误:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Negative dimension size caused by subtracting 8 from 1 for 'conv1d_2/convolution/Conv2D' (op: 'Conv2D') with input shapes: [?,1,1,32], [1,8,32,32].
I had thought it may have something to do with the size reduction due to strides, but it still does not work after setting strides=1
for both Conv1D lines. 我原以为它可能与由于步幅导致的尺寸减小有关,但是在为两个Conv1D线设置strides
strides=1
之后它仍然不起作用。 Here is my code. 这是我的代码。 If the for loop runs, then the error is thrown.
如果for循环运行,则抛出错误。
#State branch
x = Conv1D(layerSize,8,strides=1)(inputState)
x = Activation("relu")(x)
for l in range(conv1Layer-1):
x = Conv1D(layerSize,8,strides=1)(x)
x = Activation("relu")(x)
x = MaxPooling1D(pool_size=1)(x)
x = Flatten()(x)
x = Model(inputs=inputState, outputs=x)
Any help or advice would be greatly appreciated. 任何帮助或建议将不胜感激。 Thank you!
谢谢!
The kernel_size must be changed to 1 after the first layer. 必须在第一层之后将kernel_size更改为1。
EDIT: Or the padding must be set to the same! 编辑:或填充必须设置为相同! Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.