-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
Issue description
Convolutions do not raise an exception for too small input shape if stride > 1.
Code example
Suppose we have a following convolution:
conv = torch.nn.Conv2d(1, 1, kernel_size=3, dilation=2, stride=1)
tensor = torch.empty(1, 1, 4, 4)
conv(tensor).shapeThis code raises a RuntimeError: Given input size per channel: (4 x 4). Calculated output size per channel: (0 x 0). Which is quite expected.
Now change the stride to 2:
conv = torch.nn.Conv2d(1, 1, kernel_size=3, dilation=2, stride=2)
tensor = torch.empty(1, 1, 4, 4)
conv(tensor).shapeWhich gives torch.Size([1, 1, 1, 1]). Is this expected behavior?
I guess this is because in the formula for the output shape there is a division by the stride and the check is performed before taking the floor operation.
System Info
- How you installed PyTorch: conda
- OS: Linux
- PyTorch version: 0.4
- Python version: 3.6
The code was run on CPU.
Metadata
Metadata
Assignees
Labels
No labels