Question: model = nn . Linear ( 5 , 1 ) # linear model with input dim = 5 , and a single output model.weight.grad =
model nnLinear # linear model with input dim and a single output
model.weight.grad torch.Tensor
model.bias.grad torch.Tensor
maxgradnorm
torch.nnutils.clipgradnormmodelparameters maxgradnorm
printmodelweight.grad, model.bias.grad
tensor tensor
Explain why if we set maxgradnorm above, the gradient will be unchanged. Your explanation should demonstrate the calculation of where the number comes from.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
