The source code of Conv2dLocal modules is
class Conv2dLocal(Module):
def __init__(self, in_height, in_width, in_channels, out_channels,
kernel_size, stride=1, padding=0, dilation=1):
super(Conv2dLocal, self).__init__()
self.in_channels = in_channels
self.out_channels = out_channels
self.kernel_size = _pair(kernel_size)
self.stride = _pair(stride)
self.padding = _pair(padding)
self.dilation = _pair(dilation)
self.in_height = in_height
self.in_width = in_width
self.out_height = math.floor(
(in_height + 2 * self.padding[0]
- self.dilation[0] * (self.kernel_size[0] - 1) - 1)
/ self.stride[0] + 1
)
self.out_width = math.floor(
(in_width + 2 * self.padding[1]
- self.dilation[1] * (self.kernel_size[1] - 1) - 1)
/ self.stride[1] + 1
)
self.weight = Parameter(torch.Tensor(
self.out_height, self.out_width,
out_channels, in_channels, *self.kernel_size))
self.bias = Parameter(torch.Tensor(
out_channels, self.out_height, self.out_width))
self.reset_parameters()
# print(self.out_height, self.out_width, self.bias.size())
def reset_parameters(self):
n = self.in_channels
for k in self.kernel_size:
n *= k
stdv = 1. / math.sqrt(n)
self.weight.data.uniform_(-stdv, stdv)
self.bias.data.uniform_(-stdv, stdv)
def __repr__(self):
s = ('{name}({in_channels}, {out_channels}, kernel_size={kernel_size}'
', stride={stride}')
if self.padding != (0,) * len(self.padding):
s += ', padding={padding}'
if self.dilation != (1,) * len(self.dilation):
s += ', dilation={dilation}'
if self.bias is None:
s += ', bias=False'
s += ')'
return s.format(name=self.__class__.__name__, **self.__dict__)
def forward(self, input):
func = self._backend.SpatialConvolutionLocal(
self.kernel_size[1], self.kernel_size[0],
self.stride[1], self.stride[0],
self.padding[1], self.padding[0],
self.in_width, self.in_height,
self.out_width, self.out_height)
return func(input, self.weight, self.bias)
The way I use
self.conv5_local = nn.Conv2dLocal(in_channels=256, out_channels=256, in_height=8, in_width=8, kernel_size=3, stride=1, padding=0)
The bug is
TypeError: torch.FloatTensor constructor received an invalid combination of arguments - got (float, float, int, int, int, int), but expected one of:
* no arguments
* (int ...)
didn't match because some of the arguments have invalid types: (!float!, !float!, !int!, !int!, !int!, !int!)
* (torch.FloatTensor viewed_tensor)
* (torch.Size size)
* (torch.FloatStorage data)
* (Sequence data)
How do I debug for this problem?