# How to read .pt file

**URL:** <https://discuss.pytorch.org/t/how-to-read-pt-file/46996>\
**Category:** Uncategorized\
**Created:** [June 3, 2019, 9:31pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996 "2019-06-03T21:31:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![americanwallace](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/americanwallace/32/11840_2.png) [@americanwallace](https://discuss.pytorch.org/u/americanwallace)\
**Post date:** [June 3, 2019, 9:31pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/1 "2019-06-03T21:31:09Z")

</div>

I would like to know the general way to read .pt file generated by pytorch, since I want to figure out how the data is organized and read the values so that I can make some modification on it and change the structure.  
Could somebody tell me how to read that? Thank you so much.

---

<div class="post-metadata">

**Author:** ![LeviViana](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/leviviana/32/9548_2.png) [@LeviViana](https://discuss.pytorch.org/u/LeviViana)\
**Post date:** [June 3, 2019, 9:51pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/2 "2019-06-03T21:51:52Z")

</div>

You can take a look at [this tutorial](https://pytorch.org/tutorials/beginner/saving_loading_models.html) for more details on how saving and loading models in PyTorch are done.

The model’s state\_dict is just a regular python dictionary once it is loaded. Maybe [this thread](https://discuss.pytorch.org/t/loading-a-few-layers-from-a-pretrained-mdnet/45221/2) can help you understand how to manipulate it, i.e., add/or change parameters, etc.

---

<div class="post-metadata">

**Author:** ![cameroon\_etranslate](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/cameroon_etranslate/32/29941_2.png) [@cameroon\_etranslate](https://discuss.pytorch.org/u/cameroon_etranslate)\
**Post date:** [October 17, 2020, 9:08am UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/3 "2020-10-17T09:08:08Z")

</div>

I still can not make sense of it

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bramvanroy/32/28628_2.png) [@BramVanroy](https://discuss.pytorch.org/u/BramVanroy)\
**Post date:** [October 17, 2020, 9:51am UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/4 "2020-10-17T09:51:30Z")

</div>

What do you mean? You can just use `torch.load`.

---

<div class="post-metadata">

**Author:** ![cameroon\_etranslate](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/cameroon_etranslate/32/29941_2.png) [@cameroon\_etranslate](https://discuss.pytorch.org/u/cameroon_etranslate)\
**Post date:** [October 18, 2020, 6:44pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/5 "2020-10-18T18:44:35Z")

</div>

Thanks. I want to use it in Django

---

<div class="post-metadata">

**Author:** ![cameroon\_etranslate](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/cameroon_etranslate/32/29941_2.png) [@cameroon\_etranslate](https://discuss.pytorch.org/u/cameroon_etranslate)\
**Post date:** [October 19, 2020, 11:25am UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/6 "2020-10-19T11:25:29Z")

</div>

The problem is installing torch in a virtual environment keeps failing to I can’t use torch.load

 ![IMG_20201019_122512_736.jpg](https://discuss.pytorch.org/uploads/default/original/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10.jpeg)

---

<div class="post-metadata">

**Author:** ![BramVanroy](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bramvanroy/32/28628_2.png) [@BramVanroy](https://discuss.pytorch.org/u/BramVanroy)\
**Post date:** [October 19, 2020, 12:11pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/7 "2020-10-19T12:11:07Z")

</div>

Please don’t post pictures/screenshots. Post the actual code/error in text.

Seems like you just did `pip install torch` which won’t work well on Windows. Follow the guidelines here: [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)

PS: you probably want to use a fully packaged 64-bit version of Python, which you do not seem to be using right now (`wheel` missing, 32-bit version). So e.g. [this one](https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe).

---

<div class="post-metadata">

**Author:** ![Tanmay\_Baweja](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tanmay_baweja/32/30692_2.png) [@Tanmay\_Baweja](https://discuss.pytorch.org/u/Tanmay_Baweja)\
**Post date:** [November 25, 2021, 5:14pm UTC](https://discuss.pytorch.org/t/how-to-read-pt-file/46996/8 "2021-11-25T17:14:46Z")

</div>

Can models saved in .pt format be used to inference in python? I know that .pth files can be used, are .pt files used in the same way?

Thanks!
