Hi,
To make sure that a Module attribute is recognized as a learnable parameter, it needs to be wrapped in the nn.Parameter.
As you code is today, weight1 won’t actually appear in net.parameters() and so the optimizer won’t know about it.
Also for the .grad field of a Tensor to be populated, you want to make sure that it is a leaf Tensor (it has no history). Right now, because weight1 is computed based on conv.weight, it is not a leaf (you can check .is_leaf()).
You can detach it from its history to force it to be a leaf. So the updated code is:
self.weight1 = nn.Parameter((self.conv.weight * 10).detach())