In the forward hook, you are returning output.data, i usually return output. I did a run to check the type of a layer and layer.data for AlexNet, and both of them are tensor which is why you can return either, but when i checked the .requires_grad property, it seems for layer.data.requires_grad is False but layer.requires_grad is True. Try changing the output.data to output in the forward hook.