【问题标题】:Getting layer sizes wrong in matlab CNN在 matlab CNN 中获取错误的层大小
【发布时间】:2017-08-14 09:59:27
【问题描述】:

我正在尝试重现 https://arxiv.org/abs/1610.01683 中描述的卷积网络。

他们的设置概述:

但是,在尝试合并来自不同过滤器的结果时,我似乎遇到了障碍。 在论文中,作者有一个“堆叠”层,其中堆叠了 20 个不同的滤波 1D 信号,以创建一种频谱图,然后将其馈送到另一个卷积层。在matlab中如何做类似的事情?以下是我尝试过的,以及我得到的错误消息:

输入:

  inputLayer=imageInputLayer([1 6000]);
  c1=convolution2dLayer([1 200],20,'stride',1);
  p1=maxPooling2dLayer([1 20],'stride',10);
  c2=convolution2dLayer([20 30],400,'numChannels',20);
  p2=maxPooling2dLayer([1 10],'stride',[1 2]);
  f1=fullyConnectedLayer(500);
  f2=fullyConnectedLayer(500);
  s1=softmaxLayer;
  outputLayer=classificationLayer;

  convnet=[inputLayer; c1; p1; c2; p2; f1; f2; s1;outputLayer]

  opts = trainingOptions('sgdm');
  convnet = trainNetwork(allData',labels,convnet,opts);

输出:

  convnet = 

    9x1 Layer array with layers:

       1   ''   Image Input             1x6000x1 images with 'zerocenter' normalization
       2   ''   Convolution             20 1x200 convolutions with stride [1  1] and padding [0  0]
       3   ''   Max Pooling             1x20 max pooling with stride [10  10] and padding [0  0]
       4   ''   Convolution             400 20x30 convolutions with stride [1  1] and padding [0  0]
       5   ''   Max Pooling             1x10 max pooling with stride [1  2] and padding [0  0]
       6   ''   Fully Connected         500 fully connected layer
       7   ''   Fully Connected         500 fully connected layer
       8   ''   Softmax                 softmax
       9   ''   Classification Output   cross-entropy
  Error using nnet.cnn.layer.Layer>iInferSize (line 261)
  Layer 5 is expected to have a different size.

  Error in nnet.cnn.layer.Layer.inferParameters (line 53)
                  layers = iInferSize(layers, i, inputSize);

  Error in trainNetwork (line 61)
  layers = nnet.cnn.layer.Layer.inferParameters(layers);

错误消息是针对第 5 层的,但我怀疑它与第 4 层有关,即发生“堆叠”的地方。 想法?

【问题讨论】:

    标签: matlab neural-network conv-neural-network


    【解决方案1】:

    这里的根本问题是convolution2dLayer 不理解一维输入。通过深入了解细节,事实证明输入大小很快就变得毫无意义(例如负数的行数)。

    【讨论】:

      猜你喜欢
      • 2021-03-06
      • 2023-01-18
      • 2015-12-15
      • 2014-03-28
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      • 2015-12-19
      • 2020-10-17
      相关资源
      最近更新 更多