<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pth &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/pth/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:12:32 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] PyTorch模型 .pt，.pth，.pkl 的区别</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-pytorch%e6%a8%a1%e5%9e%8b-pt%ef%bc%8c-pth%ef%bc%8c-pkl-%e7%9a%84%e5%8c%ba%e5%88%ab/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-pytorch%e6%a8%a1%e5%9e%8b-pt%ef%bc%8c-pth%ef%bc%8c-pkl-%e7%9a%84%e5%8c%ba%e5%88%ab/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 18 Nov 2019 17:00:46 +0000</pubDate>
				<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[pickle]]></category>
		<category><![CDATA[pkl]]></category>
		<category><![CDATA[pt]]></category>
		<category><![CDATA[pth]]></category>
		<category><![CDATA[PyTorch]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=10950</guid>

					<description><![CDATA[<p>
我们经常会看到后缀名为 .pt，.pth，.pkl 的PyTorch模型文件，这几种模型文件在格式上有什么区别吗？<br />
其实它们并不是在格式上有区别，而只是后缀上不同而已（仅此而已）。在用 torch.save() 函数保存模型文件的时候，各人有不同的喜好，有些人喜欢用 .pt 后缀，有些人喜欢用 .pth&#160;或&#160;.pkl。用相同的 torch.save()&#160;语句保存出来的模型文件没有什么不同。<br />
在PyTorch官方的文档/代码里，<a href="https://pytorch.org/docs/master/torch.html#torch.load" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">有用 .pt 的</span></a>，<a href="https://pytorch.org/docs/master/hub.html" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">也有用 .pth 的</span></a>。<br />
据某些文章的说法，一般惯例是使用 .pth，但是官方文档里貌似 .pt&#160;更多，而且官方也不是很在意固定用一种，大家就自便吧。<br />
<span id="more-10950"></span><br />
另外，为什么会有 .pkl&#160;这种后缀名？因为 Python&#160;有一个序列化/反序列化的模块，名字叫 <span style="color:#ff0000;">pickle</span>，用它保存的文件，通常会起一个 .pkl&#160;的后缀名。torch.save()&#160;正是使用了Python pickle来保存模型的，因此使用 .pkl&#160;作为模型文件的后缀也就不奇怪了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;版权声明&#160;<span style="color: rgb(255, 0, 0);">➤➤</span>&#160;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&#160;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" />&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-pytorch%e6%a8%a1%e5%9e%8b-pt%ef%bc%8c-pth%ef%bc%8c-pkl-%e7%9a%84%e5%8c%ba%e5%88%ab/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
我们经常会看到后缀名为 .pt，.pth，.pkl 的PyTorch模型文件，这几种模型文件在格式上有什么区别吗？<br />
其实它们并不是在格式上有区别，而只是后缀上不同而已（仅此而已）。在用 torch.save() 函数保存模型文件的时候，各人有不同的喜好，有些人喜欢用 .pt 后缀，有些人喜欢用 .pth&nbsp;或&nbsp;.pkl。用相同的 torch.save()&nbsp;语句保存出来的模型文件没有什么不同。<br />
在PyTorch官方的文档/代码里，<a href="https://pytorch.org/docs/master/torch.html#torch.load" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">有用 .pt 的</span></a>，<a href="https://pytorch.org/docs/master/hub.html" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">也有用 .pth 的</span></a>。<br />
据某些文章的说法，一般惯例是使用 .pth，但是官方文档里貌似 .pt&nbsp;更多，而且官方也不是很在意固定用一种，大家就自便吧。<br />
<span id="more-10950"></span><br />
另外，为什么会有 .pkl&nbsp;这种后缀名？因为 Python&nbsp;有一个序列化/反序列化的模块，名字叫 <span style="color:#ff0000;">pickle</span>，用它保存的文件，通常会起一个 .pkl&nbsp;的后缀名。torch.save()&nbsp;正是使用了Python pickle来保存模型的，因此使用 .pkl&nbsp;作为模型文件的后缀也就不奇怪了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-pytorch%e6%a8%a1%e5%9e%8b-pt%ef%bc%8c-pth%ef%bc%8c-pkl-%e7%9a%84%e5%8c%ba%e5%88%ab/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
