class my_model(nn.Module):
  def __init__(self):
    super(my_model,self).__init__()
    self.conv1 = nn.Conv2d(3,16,kernel_size=3,stride=1,padding=1)
    self.conv2 = nn.Conv2d(16,32,kernel_size=3,stride=1,padding=1)
    self.conv3 = nn.Conv2d(32,64,kernel_size=3,stride=1,padding=1)
    self.pool = nn.MaxPool2d(2, 2)
    self.fc1 = nn.Linear(4*4*64,64)
    self.fc2 = nn.Linear(64,10)
  def forward(self,inp):
    ab = self.pool(F.relu(self.conv1(inp)))
    ab = self.pool(F.relu(self.conv2(ab)))
    ab = self.pool(F.relu(self.conv3(ab)))
    ab = ab.view(ab.shape[0],-1)
    ab = F.relu(self.fc1(ab))
    ab = F.relu(self.fc2(ab))
    return ab
    
test_model = my_model()
test_model.cuda()

I trained my model and saved it and loaded it
new_test_model = my_model()
a = torch.load("/content/cifar_net.pth")

new_test_model.load_state_dict(a)

> <all keys matched>


after that I set one filter as zero
new_test_model.conv1.weight[0]=torch.zeros_like(new_test_model.conv1.weight[0].data)
and wanted to check that after training is the filter revived
so I initialized my optimizer again
but am getting this error

ValueError: can’t optimize a non-leaf Tensor

I am not able to understand why
Please Help Me