I am trying to define a matrix to be multiplied with a vector where the weights of this matrix will be learned through the training, the issue that the weights of this matrix still unchanged  during the training here my code:
class MyNetwork(nn.Module):
    def __init__(self, device):
        super(MyNetwork, self).__init__()
        self.model = torchvision.models.densenet161(pretrained=True)              
        self.model.classifier = nn.Sequential(
                nn.Dropout(0.5),
                nn.Linear(2208, 256), 
                nn.ReLU(),
                nn.Dropout(0.5)
        )
        self.fc1 = nn.Linear(256, 23)
        self.fc2 = nn.Linear(23, 10)
        
        self.w = nn.Parameter(torch.randn(10,23).to(device), requires_grad = True)


    def forward(self, input):
        output1 = self.fc1(F.relu(self.model(input1))
        feaco1 = self.fc2(F.relu(self.drop(output1)))
        feaco2 = torch.nn.functional.one_hot(torch.argmax(feaco1, dim=1), num_classes=10).float()        
        shap1 = feaco2.matmul(self.w)
        output1 = torch.add(shap1, output1)        
 
       return output1, shap1
----------------------------------------------------------------------------
device = torch.device("cuda:2") 
model = MyNetwork(device).to(device) 
optimizer = optim.Adam(model.parameters(), lr = lr)

optimizer.zero_grad()
loss.backward()
optimizer.step() 


Did I miss anything here