I found there seems to be one additional parameter
in the torch.nn.Model
for convnet as shown in the example below. And the shape the additional parameter
seems like [in_channel, out_channl]. Can anyone help explain this?
Thanks in advance!
conv1 = torch.nn.Conv2d(1, 2, 1)
print("conv1:", conv1.weight)
class myModel(torch.nn.Module):
def __init__(self):
super(myModel, self).__init__()
self.conv1 = torch.nn.Conv2d(1, 2, 1)
def forward(self, x):
return torch.nn.functional.conv2d(x, self.filter)
model = myModel()# .cuda()
print("model:", [i for i in model.parameters()])
The output or first print
is:
conv1: Parameter containing:
tensor([[[[-0.6750]]],
[[[ 0.2480]]]], requires_grad=True)
The output of second print
is:
model: [Parameter containing:
tensor([[[[ 0.9591]]],
[[[-0.9882]]]], requires_grad=True), Parameter containing:
tensor([0.3482, 0.2676], requires_grad=True)]