如何在pytorch中将CNN模型更改为宽卷积?

时间:2017-07-04 09:12:45

标签: pytorch

我正在学习美国有线电视新闻网,我想通过pytorch改变CNN模型,他可以提供帮助吗?

self.conv23 = nn.Conv2d(Ci, len(Ks) * Co, (3, Co), padding=1)

Traceback (most recent call last):
  File "E:/workspace/pycharmworkspace/cnn-text-classification-pytorch-update/main.py", line 137, in <module>
    train.train(train_iter, dev_iter, cnn, args)
  File "E:\workspace\pycharmworkspace\cnn-text-classification-pytorch-update\train.py", line 40, in train
    logit = model(feature)
  File "C:\Users\bamtercelboo\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "E:\workspace\pycharmworkspace\cnn-text-classification-pytorch-update\model.py", line 206, in forward
    x21 = self.conv(x11, self.conv23)  #(N,Co)
  File "E:\workspace\pycharmworkspace\cnn-text-classification-pytorch-update\model.py", line 91, in conv
    x = F.relu(conv(x)).squeeze(3)  # (N,Co,W)
  File "C:\Users\bamtercelboo\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 206, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Users\bamtercelboo\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 237, in forward
    self.padding, self.dilation, self.groups)
  File "C:\Users\bamtercelboo\Anaconda3\lib\site-packages\torch\nn\functional.py", line 43, in conv2d
    return f(input, weight, bias)
RuntimeError: kernel size should be greater than zero, but got kT: 3 kH: 200 kW: 0 at d:\downloads\pytorch-master-1\torch\lib\thnn\generic/VolumetricConvolutionMM.c:23

1 个答案:

答案 0 :(得分:0)

通常这是通过调整填充参数来完成的,但我可以看到你已经处理过了。你能分享一下代码的更多信息吗?

PS很抱歉在答案中发表评论。我还不能发表评论。

我认为您可能需要调整Conv2D图层中的groups参数。