How to read .pt file

americanwallace: <p>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.<br>
Could somebody tell me how to read that? Thank you so much.</p>

LeviViana: <p>You can take a look at <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html" rel="nofollow noopener">this tutorial</a> for more details on how saving and loading models in PyTorch are done.</p>
<p>The model’s state_dict is just a regular python dictionary once it is loaded. Maybe <a href="https://discuss.pytorch.org/t/loading-a-few-layers-from-a-pretrained-mdnet/45221/2">this thread</a> can help you understand how to manipulate it, i.e., add/or change parameters, etc.</p>

cameroon_etranslate: <p>I still can not make sense of it</p>

BramVanroy: <p>What do you mean? You can just use <code>torch.load</code>.</p>

cameroon_etranslate: <p>Thanks. I want to use it in Django</p>

cameroon_etranslate: <p>The problem is installing torch in a virtual environment keeps failing to I can’t use torch.load</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/debe1f257e7bf0bfca274c88421e086e67635a10" title="IMG_20201019_122512_736.jpg"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10_2_690x320.jpeg" alt="IMG_20201019_122512_736.jpg" data-base62-sha1="vMtkB5L4xeNITtNZT2vQ7oVIJig" width="690" height="320" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10_2_690x320.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10_2_1035x480.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/e/debe1f257e7bf0bfca274c88421e086e67635a10_2_1380x640.jpeg 2x" data-dominant-color="948482"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">IMG_20201019_122512_736.jpg</span><span class="informations">4128×1920 2.56 MB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

BramVanroy: <p>Please don’t post pictures/screenshots. Post the actual code/error in text.</p>
<p>Seems like you just did <code>pip install torch</code> which won’t work well on Windows. Follow the guidelines here: <a href="https://pytorch.org/get-started/locally/" rel="noopener nofollow ugc">https://pytorch.org/get-started/locally/</a></p>
<p>PS: you probably want to use a fully packaged 64-bit version of Python, which you do not seem to be using right now (<code>wheel</code> missing, 32-bit version). So e.g. <a href="https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe" rel="noopener nofollow ugc">this one</a>.</p>

Tanmay_Baweja: <p>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?</p>
<p>Thanks!</p>