This doesn’t seem to be the right way as in my case when I updated weights this way, my gradients became non-zero even after using the optimizer.zero_grad().
For calculating features with updated weight, I used torch.nn.functional as we have conv layer already initialized in init keeping new weights in a separate variable.