Same activation at different layers

You are hooking the output of the whole block3 for each activation, I think this is what you want to do:

for layer_name, layer in module._modules.items():
     print(layer_name, layer)
     model.encoder.block3[int(layer_name)].register_forward_hook(get_activation(layer_name))
1 Like