I am trying to save activations of one of the final conv layers of a resnet101. I intend to visualize these using t_SNE. I am new to this stuff so would be really grateful if someone could help.
This is the layer I want to save :
layer = list(learn.model.modules())[-15]
This is the hook on the layer from above :
activation = {}
def get_activation(name):
def hook(model, input, output):
activation[name] = output.detach()
return hook
hook1 = layer.register_forward_hook(get_activation(layer))
This however keeps giving me error ‘NoneType’ object is not callable
learn.get_preds(data.valid_dl)
My understanding is that these predictions should generate activations that i can then visualize. Right ? Thank you for your time