Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the difference between .bin and .pt pytorch saved model types?

Tags:

pytorch

Sometimes I see .bin files for pretrained pytorch, like the one here

https://github.com/allenai/scibert#pytorch-models

However, the files are usually saved as .pt files.

What's the difference between these two parameter weights file formats? Why are there two?

like image 497
SantoshGupta7 Avatar asked Jul 28 '19 22:07

SantoshGupta7


People also ask

What is .PT in PyTorch?

A common PyTorch convention is to save tensors using . pt file extension. PyTorch preserves storage sharing across serialization. See Saving and loading tensors preserves views for more details. The 1.6 release of PyTorch switched torch.

How do you save the best model in PyTorch?

A common PyTorch convention is to save models using either a .pt or .pth file extension. Remember that you must call model.eval() to set dropout and batch normalization layers to evaluation mode before running inference. Failing to do this will yield inconsistent inference results.


1 Answers

There is no difference as it's just an extension. When it comes to UNIX-like OSes one can open the file no matter the extension (see here), Windows on the other hand is built with them in mind (here).

torch can read either .bin or .pt or .anything so it's probably convention employed by the creators of that repository.

Standard approach is to use .pt or .pth, though the second extension collides with Python's text file readable by interpreter, so .pt seems the best idea for now (see this github issue).

like image 194
Szymon Maszke Avatar answered Sep 16 '22 20:09

Szymon Maszke