# Save Pytorch Training Model in BinaryFormat insted of ZipFormat

**URL:** <https://discuss.pytorch.org/t/save-pytorch-training-model-in-binaryformat-insted-of-zipformat/135876>\
**Category:** Uncategorized\
**Created:** [November 3, 2021, 5:22pm UTC](https://discuss.pytorch.org/t/save-pytorch-training-model-in-binaryformat-insted-of-zipformat/135876 "2021-11-03T17:22:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalmanLeo93](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/45deac/32.png) [@SalmanLeo93](https://discuss.pytorch.org/u/SalmanLeo93)\
**Post date:** [November 3, 2021, 5:22pm UTC](https://discuss.pytorch.org/t/save-pytorch-training-model-in-binaryformat-insted-of-zipformat/135876/1 "2021-11-03T17:22:17Z")

</div>

I am trying to re-train the [model (solution 4)](https://github.com/SpaceNetChallenge/SpaceNet_SAR_Buildings_Solutions/blob/master/README.md) but when i save the model it saves as zip file. I have pre-trained model files from original author.  
Is there any way to save the file to .pth but in Binary format?

 ![imgonline-com-ua-twotoone-5tr4NUNHj3BmW](https://discuss.pytorch.org/uploads/default/original/3X/8/4/84e4e1ae8de805816b71aba623dcb3188a2faaa6.jpeg)

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [November 3, 2021, 7:04pm UTC](https://discuss.pytorch.org/t/save-pytorch-training-model-in-binaryformat-insted-of-zipformat/135876/2 "2021-11-03T19:04:06Z")

</div>

`torch.save` has an undocumented/not guaranteed option `_use_new_zipfile_serialization` that might help.

However, I would venture that it is better to use the new format. What is not working for you with it?

Best regards

Thomas

---

<div class="post-metadata">

**Author:** ![SalmanLeo93](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/s/45deac/32.png) [@SalmanLeo93](https://discuss.pytorch.org/u/SalmanLeo93)\
**Post date:** [November 3, 2021, 7:18pm UTC](https://discuss.pytorch.org/t/save-pytorch-training-model-in-binaryformat-insted-of-zipformat/135876/3 "2021-11-03T19:18:02Z")

</div>

\_use\_new\_zipfile\_serialization = False  
worked for me. I found it somewhere else.  
Thanks 😊
