How can i use .pth file?

i have a classification model and need to extract features map from it by freezing some layers and i did it already and got

checkpoints.pth

now i need the features in a pickle file

the file started with

OrderedDict([('pos_embed1', tensor([[[-0.0053, -0.0039,  0.0004,  ...,  0.0012,  0.0061, -0.0006],
         [ 0.0091, -0.00.....

torch.save would also use pickle under the hood and would also zip it by default. You can specify the pickle_module and pickle_protocol via the arguments.

1 Like

Thanks a lot for replying , excuse me can you give me an example

i mean the file i have which is checkpoint.pth is supposed holding the features after freezing the layers … right ?
i need to get a pickle file for those features , i searched a lot but couldn’t find the right structure

I don’t know what this file is supposed to contain or how it was created, so you could check with the author of this file.

Could you give an example, what a “pickle file” would mean in this context?
Based on the previous output, the file contains an OrderedDict and you would be able to access its content by directly indexing it. However, I’m unsure what the necessity of a “pickle file” means and why the direct indexing isn’t working for you.