Hi, I know this thread is old but for anyone else who gets here from google:
register_backward_hook will return None for grad_input[0] for the input layer if the input tensor has requires_grad=False
This doesn’t raise and error so it’s a little bit confusing, however register_hook will return an error in the same circumstance so that’s a little easier to interpret.
You can fix it with simply:
input_tensor.requires_grad = True