question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kernel size can't be greater than actual input size

See original GitHub issue

I’ve downloaded pre-trained model and deep speech.pytorch-1.1. When I try to transcribe audio, it throws RuntimeError: Calculated padded input size per channel: (61 x 6). Kernel size: (21 x 11). Kernel size can’t be greater than actual input size. Any advice?

I’m using CUDA-10.0, installations were all finished successfully.

edward@GPU-machine:~/deepspeech.pytorch-1.1$ python transcribe.py --model_path models/librispeech_pretrained.pth --audio_path fox_question.wav 
Traceback (most recent call last):
  File "transcribe.py", line 88, in <module>
    out = model(Variable(spect, volatile=True))
  File "/home/edward/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/edward/deepspeech.pytorch-1.1/model.py", line 172, in forward
    x = self.conv(x)
  File "/home/edward/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/edward/.local/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
    input = module(input)
  File "/home/edward/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/edward/.local/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 301, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: Calculated padded input size per channel: (61 x 6). Kernel size: (21 x 11). Kernel size can't be greater than actual input size at /pytorch/aten/src/THNN/generic/SpatialConvolutionMM.c:48

‘’’

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vpapaioannoucommented, Apr 7, 2020

Although in the documentation is said that “It is up to the user to add the proper padding”, it is quite tedious to calculate for each layer the proper padding. At least in PyTorch 1.4.0, the problem actually comes from torch/nn/modules/conv.py#L341. However, learning by PyTorch 1.5, https://github.com/pytorch/pytorch/blob/0475d7b08d7cba11fc0b3ea7ccbf0046fa0b1cf7/torch/nn/functional.py there is a function _pad used at https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/conv.py#L342 that can be used to solve the problem in PyTorch 1.4 as well, In PyTorch 1.4.0 this function is called pad at line 2802 of the corresponding functional.py file.

Note that PyTorch 1.4.0 is the latest stable release, at least for Anaconda( April 6 2020). Additionally, the documentation is neither clear how to pad nor the padding_mode. Code torch/nn/modules/conv.py#L341, /home/bill/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py#L2802 sheds some light on this. Nonetheless, further clarification is needed about the available options of padding. I have opened #36089 about this.

1reaction
turlvocommented, Jul 13, 2019

@Michacal I guess you already have got a answer. There is a answer in #373

You should add padding to the second convolution layer. In model.py change line 137 to:

nn.Conv2d(32, 32, kernel_size=(21, 11), stride=(2, 1), padding=(0, 5))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Kernel size can't greater than actual input size - PyTorch Forums
Hi, I'm getting the following error. RuntimeError: Calculated padded input size per channel: (1017 x 1). Kernel size: (3 x 3). Kernel size ......
Read more >
Kernel size can't be greater than actual input size
I have a data with depth = 3 and I want to pass it through 3 convolution layers with 3x3x3 kernels each ...
Read more >
An Introduction to different Types of Convolutions in Deep ...
Kernel Size : The kernel size defines the field of view of the convolution. A common choice for 2D is 3 — that...
Read more >
Which one is better in CNN, smaller input size or ... - Quora
Very small filter sizes will capture very fine details of the image. On the other hand having a bigger filter size will leave...
Read more >
Inception-v3报错:RuntimeError: Calculated padded input ...
Kernel size can't be greater than actual input size报错原因是我混用了 ... RuntimeError: Calculated padded input size per channel: (3 x 3).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found