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.