Hi,
I have the following code structure where I am updating the weights via manually defined parameter vector ‘u’
class Net(torch.nn.Module):
    def __init__(self, W):
        super(Net, self).__init__()
    
        dim=100
        self.hidden1 = nn.Linear(dim, dim, bias=False)
        self.output = nn.Linear(dim, 10)
    
        self.hidden1.weight.requires_grad = False
         
        self.u = torch.nn.Parameter(torch.randn(dim,requires_grad=True))
        self.U = torch.ger(self.u,self.u)
       
        self.hidden1.weight.data=(self.U*W)
    

    
   def forward(self, x,):
      x = self.hidden1(x)
      x = self.output(x)
   return F.log_softmax(x,dim=1)

model = Net(W)
output = model(data, target)
loss = F.nll_loss(output, target)
loss.backward()

However, the parameter ‘u’ is not getting updated by loss.backward(). Can somebody help what is the mistake I am doing here?