Open yaroslavvb opened 5 years ago
Module backward hooks may get deprecated eventually, can replace them with tensor hook as follows.
def tensor_hook_adder(module, input, output): def tensor_backwards(grad): setattr(module, 'backprops', grad) output.register_hook(tensor_backwards) layer.register_forward_hook(tensor_hook_adder)
Module backward hooks may get deprecated eventually, can replace them with tensor hook as follows.