Hello, everybody.
I have a problem I can’t understand.
loss is well calculated along with multiple layers. But after loss.backward() , all of grad.data is zero like below.
gradient of one of of my layers.
> module.module.filterDTW.proj.bias grad tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
> 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
> 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
> 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
> 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
> 0., 0., 0., 0., 0., 0., 0., 0.], device=‘cuda:0’)
from this script.
for i, (name, param) in enumerate(model.named_parameters()):
if param.grad is None:
print(name, "is None, requires_grad : ", param.requires_grad)
else:
print (name, “grad”, param.grad.data)
I’m really confused which part i have to fix
I think 1) Model output is ok 2) Initialize model weight is ok …etc
Could you share your idea for this problem?