I want to print model’s parameters with its name. I found two ways to print summary. But I want to use both requires_grad and name at same for loop. Can I do this? I want to check gradients during the training.
for p in model.parameters():
    # p.requires_grad: bool
    # p.data: Tensor

for name, param in model.state_dict().items():
    # name: str
    # param: Tensor

# my fake code
for p in model.parameters():
    if p.requires_grad:
         print(p.name, p.data)