Data Science Asked by Aaron Elliot on September 4, 2021
For some square images, I’d like to use torch.nn.Conv2d with the kernel as a vertical block. As in, the kernel size is defined as max value of the first dimension by 1. Since the first dimension has no more room, I’d like to have 0 stride along that first dimension. I tried using the following definition:
self.conv1 = torch.nn.Conv2d(3, 32, (max_dim_0, 1),
stride=(0, 1),
padding=0,
dilation=1,
groups=1,
bias=True,
padding_mode='zeros')
However, this causes my training loop throws a RuntimeError: non-positive stride is not supported
exception. Is there a way to define the kernel as a vertical block?
Setting stride to 0
is not necessary, torch
will simply compute with respect to the input tensor sizes, so you can set stride to (1,1)
.
For x
of size (batch_size, 3, max_dim_0, max_dim_0)
(square image) the tensor output will be of size (batch_size, 32, 1, max_dim_0)
.
Correct answer by Adam Oudad on September 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP