What is the difference between .pt, .pth and .pwf extentions in PyTorch?
There are no differences between the extensions that were listed: .pt
, .pth
, .pwf
. One can use whatever extension (s)he wants. So, if you're using torch.save()
for saving models, then it by default uses python pickle (pickle_module=pickle
) to save the objects and some metadata. Thus, you have the liberty to choose the extension you want, as long as it doesn't cause collisions with any other standardized extensions.
Having said that, it is however not recommended to use .pth
extension when checkpointing models because it collides with Python path (.pth
) configuration files. Because of this, I myself use .pth.tar
or .pt
but not .pth
, or any other extensions.
The standard way of checkpointing models in PyTorch is not finalized yet. Here is an open issue, as of this writing: Recommend a different file extension for models (.PTH is a special extension for Python) - issues/14864
It's been suggested by @soumith to use:
.pt
for checkpointing models in pickle format.ptc
for checkpointing models in pytorch compiled (for JIT)
The file extension does not change anything in the saved file. The recommended extensions are just used in order to make everyone recognize that it actually is a model saved from pytorch. However, pytorch actually uses python built-in pickle module (https://docs.python.org/2/library/pickle.html)