Solved by ptrblck in post #4 
              
              
                It seems to work using this small example: 
act_in = {}
act_out = {}
def get_hook(name):
    def hook(m, input, output):
        act_in[name] = input[0].detach()
        act_out[name] = output.detach()
    return hook
        

model = nn.Sequential(
    nn.Conv2d(3, 6, 3, 1, 1),
    nn.ReLU(),
    …