Hi,
Given how you set the weights, what most likely happens is that you set the weights after passing them to the optimizer?
In that case, the weights that the optimizer get are not in the model anymore and so that won’t work.
If you just want to change the values of the weight, you can implement it as:
    def set_weight(self, tensor):
        with torch.no_grad():
            self.weight.copy_(tensor)

This way, the parameter given to the optimizer won’t change.