I want to use the pretrained models, such as resnet101, and get the features after the layer 4, and save them. I dont want to load a pretrained model because i dont have memory to do that
Then have another model that i want to use those saved features.
To clarify, the features that i want to save have size of 1x1024xWxH and when I reload them I don’t care if they have auto_grad to be True or False.
How can i save the features and then read them and use them in a new model?
Why am I doing it? My second model is too big and already slow that i dont wanna add another thing on the top of it
I think this question is the same as how to save and reuse the following tensor A: A = torch.rand(1,1024,10,10)
If you would like to store the activations, you could use forward hook as described in this example. Instead of the print statements use torch.save to save the activations using the dict.
Later, you can restore these activations using torch.load and use them as your training samples for the second model.