简体   繁体   English

多个Conv1D图层:由于'conv1d_2 / convolution / Conv2D从1中减去8而导致的负尺寸大小

[英]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! 谢谢!

If you do not want the length to change after the convolution consider specifying padding='same' in the constructor of Conv1d . 如果您不想在卷积后更改长度,请考虑在Conv1d的构造函数中指定padding='same'

For more info see the docs . 有关详细信息,请参阅文档

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.

相关问题 'Conv2D' 从 1 中减去 3 导致的负尺寸大小 - Negative dimension size caused by subtracting 3 from 1 for 'Conv2D' 'conv2d_2/convolution' 从 1 中减去 3 导致的负维度大小 - Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution' '{{node conv2d_3/Conv2D} 从 1 中减去 3 导致的负维度大小 - Negative dimension size caused by subtracting 3 from 1 for '{{node conv2d_3/Conv2D} ValueError:'{{node conv2d_3/Conv2D}} 从 1 中减去 2 导致的负维度大小 - ValueError: Negative dimension size caused by subtracting 2 from 1 for '{{node conv2d_3/Conv2D}} InvalidArgumentError: 1减3导致的负维度大小'{{node conv2d_28/Conv2D}} - InvalidArgumentError: Negative dimension size caused by subtracting 3 from 1 '{{node conv2d_28/Conv2D}} ValueError:由 1 为 'conv3d_3/convolution' 减去 22 引起的负尺寸大小(操作:'Conv3D') - ValueError: Negative dimension size caused by subtracting 22 from 1 for 'conv3d_3/convolution' (op: 'Conv3D') “ Encoder / conv6 / Conv2D”的2减去3导致的负尺寸大小 - Negative dimension size caused by subtracting 3 from 2 for 'Encoder/conv6/Conv2D' 输入形状为 [?,1,10000,80], [3,3,80,16] 的 'conv2d_1/convolution'(操作:'Conv2D')从 1 中减去 3 导致的负尺寸大小 - Negative dimension size caused by subtracting 3 from 1 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,1,10000,80], [3,3,80,16] 负维度大小由 2 减去 5 导致的 'conv2d_4/convolution' (op: 'Conv2D') 输入形状:[?,5,2,64], [5,5,64,64] - Negative dimension size caused by subtracting 5 from 2 for 'conv2d_4/convolution' (op: 'Conv2D') with input shapes: [?,5,2,64], [5,5,64,64] 输入形状为 [?,1,74,16], [3,3,16,32] 的“conv2d_2/convolution”(操作:“Conv2D”)从 1 中减去 3 导致的负尺寸大小 - Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution' (op: 'Conv2D') with input shapes: [?,1,74,16], [3,3,16,32]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM