The dimensions are not correct: you are assigning a [1, 1, 5]
tensor to the weights, whereas self.conv1.weight.size()
is torch.Size([5, 1, 1, 1])
.
Try:
self.conv1.weight = torch.nn.Parameter(torch.ones_like(self.conv1.weight))
and it will work !