Hi, faced a problem:
Trying to implement nn.Conv2d by myself.
Init method:
self.filters = Variable(
torch.randn(
self.n_filters,
self.input_depth,
self.kernel_size,
self.kernel_size
)
)
self.bias = torch.autograd.Variable(torch.from_numpy(np.zeros(n_filters, dtype=‘float32’)))
self.params = [self.filters, self.bias]
Forward method:
self.output = torch.nn.functional.conv2d(
x,
self.filters,
bias=self.bias,
stride=self.stride,
padding=self.padding
)
But in the optimizer, when I call parameter.grad, it is None.
P.s. x is not one image. It consists of several input images in one tensor.
Thanks in advance for your help!