How do I find Framework Version of .pt/.pth Model File?

Hi, I tried

model=torch.load("densenet121.pth")
model._version

which gives 1.
First, I am not sure if this 1 means the major version of the torch or the version of the model.
Even if it is the major version of the torch, the number is not useful.

Is there a way to find out which 1.x the model file is using?

Thanks

No, this is very likely not the PyTorch version, but an internal version of the model.
The recommendation is to not serialize models but only state dicts for somewhat related reasons (Python takes the class from the source code and the object from the serialization and this gives rather not-nice-to-debug failure modes).

It’s probably not that useful to you now, but if you save state dicts instead of models, the backward compatibility between PyTorch versions is quite reasonable.

Best regards

Thomas