Forward function AttributeError: 'NoneType' object has no attribute 'data'

I am training a U-Net like and I am getting this error after backpropagation.

    grads = [p.grad.data for p in params]
AttributeError: 'NoneType' object has no attribute 'data'

I read that the problem can be that in the forward function not every layer is been called. How can I easily detect which one is causing the problem? I debugged the forward function and it seems ok to me.

That means some parameters weren’t updated (code bug or broken computational graph). param.grad is None by default and NoneType has no object data