Skip to content

Incorrect error message when using nn.functional.convNd() and nn.functional.conv_transposeNd() #5696

@vishwakftw

Description

@vishwakftw
  • OS: Ubuntu 16.04
  • PyTorch version: 0.3.0.post4
  • How you installed PyTorch (conda, pip, source): pip
  • Python version: 3.5.2
  • CUDA/cuDNN version: CUDA 8

The below script produces an incorrect error message (torch.nn.functional.convNd)

>>> input = torch.autograd.Variable(torch.randn(10, 3, 28, 28, 28))
>>> weight = torch.autograd.Variable(torch.randn(20, 3, 4, 7))
>>> torch.nn.functional.conv3d(input, weight)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 126, in conv3d
    return f(input, weight, bias)
RuntimeError: Expected 5-dimensional input for 5-dimensional weight [10, 3, 4, 7], but got input of size [10, 3, 28, 28, 28] instead

>>> torch.nn.functional.conv2d(input[..., -1], weight[..., -1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 90, in conv2d
    return f(input, weight, bias)
RuntimeError: Expected 4-dimensional input for 4-dimensional weight [10, 3, 4], but got input of size [10, 3, 28, 28] instead

>>> torch.nn.functional.conv1d(input[..., -1, -1], weight[..., -1, -1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 54, in conv1d
    return f(input, weight, bias)
RuntimeError: Expected 3-dimensional input for 3-dimensional weight [10, 3], but got input of size [10, 3, 28] instead

The below script produces an incorrect error message (torch.nn.functional.conv_transposeNd)

>>> input = torch.autograd.Variable(torch.randn(10, 3, 28, 28, 28))
>>> weight = torch.autograd.Variable(torch.randn(3, 10, 2, 12))
>>> torch.nn.functional.conv_transpose3d(input, weight)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 224, in conv_transpose3d
    return f(input, weight, bias)
RuntimeError: Expected 5-dimensional input for 5-dimensional weight [3, 10, 2, 12], but got input of size [10, 3, 28, 28, 28] instead

>>> torch.nn.functional.conv_transpose2d(input[..., -1], weight[..., -1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 192, in conv_transpose2d
    return f(input, weight, bias)
RuntimeError: Expected 4-dimensional input for 4-dimensional weight [3, 10, 2], but got input of size [10, 3, 28, 28] instead

>>> torch.nn.functional.conv_transpose1d(input[..., -1, -1], weight[..., -1, -1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 159, in conv_transpose1d
    return f(input, weight, bias)
RuntimeError: Expected 3-dimensional input for 3-dimensional weight [3, 10], but got input of size [10, 3, 28] instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions