<?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>未分类 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/category/%E6%9C%AA%E5%88%86%E7%B1%BB/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Fri, 24 Dec 2021 03:13:19 +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>[原创] IntelliJ IDEA打开大JSON文件的高亮配置</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea%e6%89%93%e5%bc%80%e5%a4%a7json%e6%96%87%e4%bb%b6%e7%9a%84%e9%ab%98%e4%ba%ae%e9%85%8d%e7%bd%ae/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea%e6%89%93%e5%bc%80%e5%a4%a7json%e6%96%87%e4%bb%b6%e7%9a%84%e9%ab%98%e4%ba%ae%e9%85%8d%e7%bd%ae/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Thu, 20 May 2021 18:14:15 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13314</guid>

					<description><![CDATA[<p>如果你在 IntelliJ IDEA&#160;中打开一个比较大的JSON文件，可能会在IDE上方看到这样的提示：</p>
<blockquote>
<p>
		The file size (xxx MB) exceeds the configured limit (2.56MB). Code insight features are not available.</p>
</blockquote>
<p>这说明默认配置是：大小不超过 2.56MB&#160;的文件，打开才有语法高亮显示，以及代码块折叠功能（代码编辑区域左侧点击 +、-&#160;符号折叠同一段代码）。<br />
<span id="more-13314"></span><br />
你可以自定义配置增大这个值，方法：<br />
点击菜单 <span style="color:#ff0000;">Help-&#62;Edit Custom Properties</span>，如果你以前没有自定义过，那么配置文件会不存在，按提示选择创建配置文件 idea.properties，在里面填上如下内容：</p>
<pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">
<span style="color:#8c8c8c;font-style:italic;">#---------------------------------------------------------------------
</span><span style="color:#8c8c8c;font-style:italic;"># Maximum file size (kilobytes) IDE should provide code assistance for.</span></pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-intellij-idea%e6%89%93%e5%bc%80%e5%a4%a7json%e6%96%87%e4%bb%b6%e7%9a%84%e9%ab%98%e4%ba%ae%e9%85%8d%e7%bd%ae/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>如果你在 IntelliJ IDEA&nbsp;中打开一个比较大的JSON文件，可能会在IDE上方看到这样的提示：</p>
<blockquote>
<p>
		The file size (xxx MB) exceeds the configured limit (2.56MB). Code insight features are not available.</p>
</blockquote>
<p>这说明默认配置是：大小不超过 2.56MB&nbsp;的文件，打开才有语法高亮显示，以及代码块折叠功能（代码编辑区域左侧点击 +、-&nbsp;符号折叠同一段代码）。<br />
<span id="more-13314"></span><br />
你可以自定义配置增大这个值，方法：<br />
点击菜单 <span style="color:#ff0000;">Help-&gt;Edit Custom Properties</span>，如果你以前没有自定义过，那么配置文件会不存在，按提示选择创建配置文件 idea.properties，在里面填上如下内容：</p>
<pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">
<span style="color:#8c8c8c;font-style:italic;">#---------------------------------------------------------------------
</span><span style="color:#8c8c8c;font-style:italic;"># Maximum file size (kilobytes) IDE should provide code assistance for.
</span><span style="color:#8c8c8c;font-style:italic;"># The larger file is the slower its editor works and higher overall system memory requirements are
</span><span style="color:#8c8c8c;font-style:italic;"># if code assistance is enabled. Remove this property or set to very large number if you need
</span><span style="color:#8c8c8c;font-style:italic;"># code assistance for any files available regardless their size.
</span><span style="color:#8c8c8c;font-style:italic;">#---------------------------------------------------------------------
</span><span style="color:#083080;">idea.max.intellisense.filesize</span>=<span style="color:#067d17;">5120
</span></pre>
<p>
5120单位为KB，表示把文件大小限制设置成5MB。<br />
之后重新启动 IntelliJ IDEA，即可生效。<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-intellij-idea%e6%89%93%e5%bc%80%e5%a4%a7json%e6%96%87%e4%bb%b6%e7%9a%84%e9%ab%98%e4%ba%ae%e9%85%8d%e7%bd%ae/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 二维numpy数组保存到TFRecord并读取还原回来</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%ba%8c%e7%bb%b4numpy%e6%95%b0%e7%bb%84%e4%bf%9d%e5%ad%98%e5%88%b0tfrecord%e5%b9%b6%e8%af%bb%e5%8f%96%e8%bf%98%e5%8e%9f%e5%9b%9e%e6%9d%a5/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%ba%8c%e7%bb%b4numpy%e6%95%b0%e7%bb%84%e4%bf%9d%e5%ad%98%e5%88%b0tfrecord%e5%b9%b6%e8%af%bb%e5%8f%96%e8%bf%98%e5%8e%9f%e5%9b%9e%e6%9d%a5/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Wed, 18 Sep 2019 10:44:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[numpy array]]></category>
		<category><![CDATA[TensorFlow]]></category>
		<category><![CDATA[TFRecord]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=10534</guid>

					<description><![CDATA[<p>
TensorFlow版本：1.14.0<br />
Python版本：3.6.8</p>
<p>TFRecord 文件格式是一种面向记录的简单二进制格式，很多 TensorFlow 应用采用此格式来训练数据。<br />
TFRecord 内部有一系列的 Example ，Example 是 protocolbuf 协议下的消息体。<br />
<span id="more-10534"></span><br />
把一个一维的numpy数组保存为TFRecord文件很容易，但如果numpy数组是二维的可能就比较容易写错。下面是一个例子。</p>
<ol class="dp-py" start="1" style="box-sizing: border-box; margin: 0px 0px 5px; padding: 2px; color: rgb(102, 102, 102); overflow-wrap: break-word; list-style: none; font-family: &#34;Microsoft Yahei&#34;, Helvetica, Arial, sans-serif; font-size: 15px;">
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#34;&#34;&#34;</span>&#160;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">本程序演示了如何保存numpy&#160;array为TFRecords文件，并将其读取出来。</span>&#160;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#34;&#34;&#34;</span><span style="box-sizing: border-box;">&#160;&#160;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&#160;</span><span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">&#160;&#160;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&#160;&#160;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&#160;numpy&#160;as&#160;np&#160;&#160;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&#160;tensorflow&#160;as&#160;tf&#160;&#160;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&#160;&#160;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">__author__</span><span style="box-sizing: border-box;">&#160;=&#160;&#39;Darran&#160;Zhang&#160;@&#160;codelast.com&#39;&#160;&#160;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&#160;&#160;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&#160;&#160;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">def</span><span style="box-sizing: border-box;">&#160;save_tfrecords(state_data,&#160;action_data,&#160;reward_data,&#160;dest_file):&#160;&#160;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&#160;&#160;&#160;&#160;<span class="string" style="box-sizing: border-box; color: red;">&#34;&#34;&#34;</span>&#160;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#160;&#160;&#160;&#160;保存numpy&#160;array到TFRecord文件中。</span>&#160;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#160;&#160;&#160;&#160;这里输入了三个不同的numpy&#160;array来做演示，它们含有不同类型的元素。</span>&#160;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#160;&#160;&#160;&#160;Args:</span>&#160;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;state_data:&#160;要保存到TFRecord文件的第1个numpy&#160;array，每一个&#160;state_data[i]&#160;是一个&#160;numpy.ndarray（数组里的每个元素又是一个浮点</span></span></li></ol>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%ba%8c%e7%bb%b4numpy%e6%95%b0%e7%bb%84%e4%bf%9d%e5%ad%98%e5%88%b0tfrecord%e5%b9%b6%e8%af%bb%e5%8f%96%e8%bf%98%e5%8e%9f%e5%9b%9e%e6%9d%a5/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
TensorFlow版本：1.14.0<br />
Python版本：3.6.8</p>
<p>TFRecord 文件格式是一种面向记录的简单二进制格式，很多 TensorFlow 应用采用此格式来训练数据。<br />
TFRecord 内部有一系列的 Example ，Example 是 protocolbuf 协议下的消息体。<br />
<span id="more-10534"></span><br />
把一个一维的numpy数组保存为TFRecord文件很容易，但如果numpy数组是二维的可能就比较容易写错。下面是一个例子。</p>
<ol class="dp-py" start="1" style="box-sizing: border-box; margin: 0px 0px 5px; padding: 2px; color: rgb(102, 102, 102); overflow-wrap: break-word; list-style: none; font-family: &quot;Microsoft Yahei&quot;, Helvetica, Arial, sans-serif; font-size: 15px;">
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&quot;&quot;&quot;</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">本程序演示了如何保存numpy&nbsp;array为TFRecords文件，并将其读取出来。</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&quot;&quot;&quot;</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&nbsp;</span><span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&nbsp;numpy&nbsp;as&nbsp;np&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">import</span><span style="box-sizing: border-box;">&nbsp;tensorflow&nbsp;as&nbsp;tf&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">__author__</span><span style="box-sizing: border-box;">&nbsp;=&nbsp;&#39;Darran&nbsp;Zhang&nbsp;@&nbsp;codelast.com&#39;&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">def</span><span style="box-sizing: border-box;">&nbsp;save_tfrecords(state_data,&nbsp;action_data,&nbsp;reward_data,&nbsp;dest_file):&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="string" style="box-sizing: border-box; color: red;">&quot;&quot;&quot;</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;保存numpy&nbsp;array到TFRecord文件中。</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;这里输入了三个不同的numpy&nbsp;array来做演示，它们含有不同类型的元素。</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;Args:</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_data:&nbsp;要保存到TFRecord文件的第1个numpy&nbsp;array，每一个&nbsp;state_data[i]&nbsp;是一个&nbsp;numpy.ndarray（数组里的每个元素又是一个浮点</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数），因此不能用&nbsp;Int64List&nbsp;或&nbsp;FloatList&nbsp;来存储，只能用&nbsp;BytesList。</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action_data:&nbsp;要保存到TFRecord文件的第2个numpy&nbsp;array，每一个&nbsp;action_data[i]&nbsp;是一个整数，使用&nbsp;Int64List&nbsp;来存储。</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reward_data:&nbsp;要保存到TFRecord文件的第3个numpy&nbsp;array，每一个&nbsp;reward_data[i]&nbsp;是一个整数，使用&nbsp;Int64List&nbsp;来存储。</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest_file:&nbsp;输出文件的路径。</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;Returns:</span>&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不返回任何值</span>&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="string" style="box-sizing: border-box; color: red;">&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;tf.io.TFRecordWriter(dest_file)&nbsp;as&nbsp;writer:&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">for</span><span style="box-sizing: border-box;">&nbsp;i&nbsp;</span><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">in</span><span style="box-sizing: border-box;">&nbsp;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">range</span><span style="box-sizing: border-box;">(</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">len</span><span style="box-sizing: border-box;">(state_data)):&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;features&nbsp;=&nbsp;tf.train.Features(&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;feature={&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;state&quot;:&nbsp;tf.train.Feature(&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bytes_list=tf.train.BytesList(value=[state_data[i].astype(np.float32).tostring()])),&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;action&quot;:&nbsp;tf.train.Feature(&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int64_list=tf.train.Int64List(value=[action_data[i]])),&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;reward&quot;:&nbsp;tf.train.Feature(&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int64_list=tf.train.Int64List(value=[reward_data[i]]))&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tf_example&nbsp;=&nbsp;tf.train.Example(features=features)&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serialized&nbsp;=&nbsp;tf_example.SerializeToString()&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">write</span><span style="box-sizing: border-box;">(serialized)&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">def</span><span style="box-sizing: border-box;">&nbsp;parse_fn(example_proto):&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;features&nbsp;=&nbsp;{&quot;state&quot;:&nbsp;tf.FixedLenFeature((),&nbsp;tf.<span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">string</span><span style="box-sizing: border-box;">),&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;action&quot;:&nbsp;tf.FixedLenFeature((),&nbsp;tf.int64),&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;reward&quot;:&nbsp;tf.FixedLenFeature((),&nbsp;tf.int64)}&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;parsed_features&nbsp;=&nbsp;tf.parse_single_example(example_proto,&nbsp;features)&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">return</span><span style="box-sizing: border-box;">&nbsp;tf.decode_raw(parsed_features[&#39;state&#39;],&nbsp;tf.float32),&nbsp;parsed_features[&#39;action&#39;],&nbsp;parsed_features[&#39;reward&#39;]&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;"><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">if</span><span style="box-sizing: border-box;">&nbsp;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">__name__</span><span style="box-sizing: border-box;">&nbsp;==&nbsp;&#39;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">__main__</span><span style="box-sizing: border-box;">&#39;:&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;buffer_s,&nbsp;buffer_a,&nbsp;buffer_r&nbsp;=&nbsp;[],&nbsp;[],&nbsp;[]&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;随机生成一些数据</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">for</span><span style="box-sizing: border-box;">&nbsp;i&nbsp;</span><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">in</span><span style="box-sizing: border-box;">&nbsp;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">range</span><span style="box-sizing: border-box;">(3):&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state&nbsp;=&nbsp;[<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">round</span><span style="box-sizing: border-box;">(</span><span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">.</span><span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">()&nbsp;*&nbsp;100,&nbsp;2)&nbsp;</span><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">for</span><span style="box-sizing: border-box;">&nbsp;_&nbsp;</span><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">in</span><span style="box-sizing: border-box;">&nbsp;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">range</span><span style="box-sizing: border-box;">(0,&nbsp;10)]&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;一个数组，里面有10个数，每个都是一个浮点数</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action&nbsp;=&nbsp;<span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">.randrange(0,&nbsp;2)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;一个数，值为&nbsp;0&nbsp;或&nbsp;1</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reward&nbsp;=&nbsp;<span class="commonlibs" style="box-sizing: border-box; color: rgb(138, 43, 226); font-style: italic;">random</span><span style="box-sizing: border-box;">.randrange(0,&nbsp;100)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;一个数，值域&nbsp;[0,&nbsp;100)</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;把生成的数分别添加到3个list中</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer_s.<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">append</span><span style="box-sizing: border-box;">(state)&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer_a.<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">append</span><span style="box-sizing: border-box;">(action)&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer_r.<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">append</span><span style="box-sizing: border-box;">(reward)&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;查看生成的数据</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(buffer_s)&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(buffer_a)&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(buffer_r)&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;在水平方向把各个list堆叠起来，堆叠的结果：得到3个矩阵</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;s_stacked&nbsp;=&nbsp;np.vstack(buffer_s)&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;a_stacked&nbsp;=&nbsp;np.vstack(buffer_a)&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;r_stacked&nbsp;=&nbsp;np.vstack(buffer_r)&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(s_stacked.shape)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;(3,&nbsp;10)</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(a_stacked.shape)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;(3,&nbsp;1)</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(r_stacked.shape)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;(3,&nbsp;1)</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;写入TFRecord文件</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;output_file&nbsp;=&nbsp;&#39;./data.tfrecord&#39;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;输出文件的路径</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;save_tfrecords(s_stacked,&nbsp;a_stacked,&nbsp;r_stacked,&nbsp;output_file)&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;读取TFRecord文件并打印出其内容</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">for</span><span style="box-sizing: border-box;">&nbsp;example&nbsp;</span><span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">in</span><span style="box-sizing: border-box;">&nbsp;tf.io.tf_record_iterator(output_file):&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(tf.train.Example.FromString(example))&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;或者用下面的方法</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;from&nbsp;google.protobuf.json_format&nbsp;import&nbsp;MessageToJson</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;jsonMessage&nbsp;=&nbsp;MessageToJson(tf.train.Example.FromString(example))</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;print(jsonMessage)</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;读取TFRecord文件并还原成numpy&nbsp;array，再打印出来</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;tf.Session()&nbsp;as&nbsp;sess:&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset&nbsp;=&nbsp;tf.data.TFRecordDataset(output_file)&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;加载TFRecord文件</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset&nbsp;=&nbsp;dataset.<span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">map</span><span style="box-sizing: border-box;">(parse_fn)&nbsp;&nbsp;</span><span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;解析data到Tensor</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset&nbsp;=&nbsp;dataset.repeat(1)&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;重复N&nbsp;epochs</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataset&nbsp;=&nbsp;dataset.batch(3)&nbsp;&nbsp;<span class="comment" style="box-sizing: border-box; color: green;">#&nbsp;batch&nbsp;size</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iterator&nbsp;=&nbsp;dataset.make_one_shot_iterator()&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next_data&nbsp;=&nbsp;iterator.get_next()&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;</span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">while</span><span style="box-sizing: border-box;">&nbsp;</span><span class="builtins" style="box-sizing: border-box; color: rgb(255, 20, 147);">True</span><span style="box-sizing: border-box;">:&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">try</span><span style="box-sizing: border-box;">:&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state,&nbsp;action,&nbsp;reward&nbsp;=&nbsp;sess.run(next_data)&nbsp;&nbsp;</span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(state)&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(action)&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">print</span><span style="box-sizing: border-box;">(reward)&nbsp;&nbsp;</span></span></li>
<li class="alt" style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">except</span><span style="box-sizing: border-box;">&nbsp;tf.errors.OutOfRangeError:&nbsp;&nbsp;</span></span></li>
<li style="box-sizing: border-box; border-left: 1px dashed rgb(204, 204, 204); padding-left: 10px; line-height: 28.5px; margin: 0px 35px 0px 50px; list-style: decimal;">
		<span style="box-sizing: border-box; color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword" style="box-sizing: border-box; color: blue; font-weight: bold;">break</span><span style="box-sizing: border-box;">&nbsp;&nbsp;</span></span></li>
</ol>
<p>
注意：对二维数组，需要用&nbsp;tf.train.BytesList 来保存，还原成numpy array的时候，要用&nbsp;tf.decode_raw() 来解析。<br />
由于生成的数据是随机数，因此你看到的输出会和我不一样。<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 />
生成的数据：</p>
<blockquote>
<div>
		[[56.31, 8.72, 78.21, 44.52, 98.18, 95.23, 85.89, 95.76, 63.96, 41.56], [21.78, 66.52, 17.58, 35.36, 29.25, 63.54, 49.12, 82.71, 77.38, 20.04], [65.86, 78.81, 17.64, 3.21, 60.88, 92.98, 80.63, 92.86, 80.7, 4.12]]</div>
<div>
		[1, 0, 1]</div>
<div>
		[55, 97, 89]</div>
</blockquote>
<p>
numpy数组写成TFRecord后再重新读取出来，并重新转成numpy数组后，数据是：</p>
<blockquote>
<div>
		[[56.31&nbsp; 8.72 78.21 44.52 98.18 95.23 85.89 95.76 63.96 41.56]</div>
<div>
		&nbsp;[21.78 66.52 17.58 35.36 29.25 63.54 49.12 82.71 77.38 20.04]</div>
<div>
		&nbsp;[65.86 78.81 17.64&nbsp; 3.21 60.88 92.98 80.63 92.86 80.7&nbsp; &nbsp;4.12]]</div>
<div>
		[1 0 1]</div>
<div>
		[55 97 89]</div>
</blockquote>
<p>可见数据和生成的一样，这说明上面的程序互相转没有问题。</p>
<p><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-%e4%ba%8c%e7%bb%b4numpy%e6%95%b0%e7%bb%84%e4%bf%9d%e5%ad%98%e5%88%b0tfrecord%e5%b9%b6%e8%af%bb%e5%8f%96%e8%bf%98%e5%8e%9f%e5%9b%9e%e6%9d%a5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] Cauchy-Schwartz(柯西-施瓦茨)不等式复习</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-cauchy-schwartz%e6%9f%af%e8%a5%bf-%e8%ae%b8%e7%93%a6%e5%85%b9%e4%b8%8d%e7%ad%89%e5%bc%8f%e5%a4%8d%e4%b9%a0/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-cauchy-schwartz%e6%9f%af%e8%a5%bf-%e8%ae%b8%e7%93%a6%e5%85%b9%e4%b8%8d%e7%ad%89%e5%bc%8f%e5%a4%8d%e4%b9%a0/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Wed, 02 Apr 2014 15:07:22 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Cauchy-Schwartz inequality]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[最优化]]></category>
		<category><![CDATA[柯西不等式]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=8022</guid>

					<description><![CDATA[<p>
<a href="http://zh.wikipedia.org/wiki/%E6%9F%AF%E8%A5%BF-%E6%96%BD%E7%93%A6%E8%8C%A8%E4%B8%8D%E7%AD%89%E5%BC%8F" rel="noopener noreferrer" target="_blank"><span style="color:#0000ff;">柯西-</span>施瓦茨<span style="color:#0000ff;">不等式</span></a>，又叫<span style="color:#0000ff;">柯西不等式</span>，<span style="color:#0000ff;">施瓦茨不等式</span>，<span style="color:#0000ff;">柯西-布尼亚科夫斯基-施瓦茨不等式</span>，等等，中文名太多了，它是最重要的数学不等式之一，如下：<br />
<span id="more-8022"></span><br />
<span style="color:#b22222;"> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_cb74bbb01f35d004cc6a7e9f6230ec62.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n})^2} \le (a_1^2 + a_2^2 + \cdots + a_n^2)(b_1^2 + b_2^2 + \cdots + b_n^2)" /></span><script type='math/tex'>{({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n})^2} \le (a_1^2 + a_2^2 + \cdots + a_n^2)(b_1^2 + b_2^2 + \cdots + b_n^2)</script> </span><br />
<!--more--><br />
两边开方，它与下面的不等式是等价的：<br />
<span style="color:#b22222;"> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_2faef7bfff1303da60951a77f6c7d4d0.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n}) \le \sqrt {(a_1^2 + a_2^2 + \cdots + a_n^2)} \sqrt {(b_1^2 + b_2^2 + \cdots + b_n^2)} " /></span><script type='math/tex'>({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n}) \le \sqrt {(a_1^2 + a_2^2 + \cdots + a_n^2)} \sqrt {(b_1^2 + b_2^2 + \cdots + b_n^2)} </script> </span><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-cauchy-schwartz%e6%9f%af%e8%a5%bf-%e8%ae%b8%e7%93%a6%e5%85%b9%e4%b8%8d%e7%ad%89%e5%bc%8f%e5%a4%8d%e4%b9%a0/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
<a href="http://zh.wikipedia.org/wiki/%E6%9F%AF%E8%A5%BF-%E6%96%BD%E7%93%A6%E8%8C%A8%E4%B8%8D%E7%AD%89%E5%BC%8F" rel="noopener noreferrer" target="_blank"><span style="color:#0000ff;">柯西-</span>施瓦茨<span style="color:#0000ff;">不等式</span></a>，又叫<span style="color:#0000ff;">柯西不等式</span>，<span style="color:#0000ff;">施瓦茨不等式</span>，<span style="color:#0000ff;">柯西-布尼亚科夫斯基-施瓦茨不等式</span>，等等，中文名太多了，它是最重要的数学不等式之一，如下：<br />
<span id="more-8022"></span><br />
<span style="color:#b22222;"> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_cb74bbb01f35d004cc6a7e9f6230ec62.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n})^2} \le (a_1^2 + a_2^2 + \cdots + a_n^2)(b_1^2 + b_2^2 + \cdots + b_n^2)" /></span><script type='math/tex'>{({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n})^2} \le (a_1^2 + a_2^2 + \cdots + a_n^2)(b_1^2 + b_2^2 + \cdots + b_n^2)</script> </span><br />
<!--more--><br />
两边开方，它与下面的不等式是等价的：<br />
<span style="color:#b22222;"> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_2faef7bfff1303da60951a77f6c7d4d0.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n}) \le \sqrt {(a_1^2 + a_2^2 + \cdots + a_n^2)} \sqrt {(b_1^2 + b_2^2 + \cdots + b_n^2)} " /></span><script type='math/tex'>({a_1}{b_1} + {a_2}{b_2} + \cdots + {a_n}{b_n}) \le \sqrt {(a_1^2 + a_2^2 + \cdots + a_n^2)} \sqrt {(b_1^2 + b_2^2 + \cdots + b_n^2)} </script> </span><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
当且仅当：<br />
<span style="color:#0000ff;"> <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_6337b1fff757e26d559865b0f907b86f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\frac{{{a_1}}}{{{b_1}}} = \frac{{{a_2}}}{{{b_2}}} = \cdots = \frac{{{a_n}}}{{{b_n}}}" /></span><script type='math/tex'>\frac{{{a_1}}}{{{b_1}}} = \frac{{{a_2}}}{{{b_2}}} = \cdots = \frac{{{a_n}}}{{{b_n}}}</script> </span><br />
时等号成立。</p>
<p><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-cauchy-schwartz%e6%9f%af%e8%a5%bf-%e8%ae%b8%e7%93%a6%e5%85%b9%e4%b8%8d%e7%ad%89%e5%bc%8f%e5%a4%8d%e4%b9%a0/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>[原创]高等数学笔记(2)</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%ab%98%e7%ad%89%e6%95%b0%e5%ad%a6%e7%ac%94%e8%ae%b02/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%ab%98%e7%ad%89%e6%95%b0%e5%ad%a6%e7%ac%94%e8%ae%b02/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 14 Jul 2013 07:20:35 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[蔡高厅高等数学]]></category>
		<category><![CDATA[高数教程]]></category>
		<category><![CDATA[高数笔记]]></category>
		<category><![CDATA[高等数学教程]]></category>
		<category><![CDATA[高等数学笔记]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=6253</guid>

					<description><![CDATA[<p>
<span style="background-color: rgb(0, 255, 0);">【前言】</span><br />
请看<a href="http://www.codelast.com/?p=6183" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">此文</span></a>。<br />
要查看高等数学笔记合集，请看<a href="http://www.codelast.com/?p=6363" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这里</span></a>。</p>
<p><span style="background-color: rgb(0, 255, 0);">【正文】</span><br />
<span style="color:#ff0000;">去心邻域</span>：把 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_bf08fb50b5b569418c85efdd6ffe739f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="N(a,\delta )" /></span><script type='math/tex'>N(a,\delta )</script> 的中心点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 去掉，称为点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 的去心邻域，记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_339fa6064fd5a3881d24750686ea8cb9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="N(\hat a,\delta ) = \{ x&#124;0 < &#124;x - a&#124; < \delta\} = N(a,\delta )\backslash \{ a\} " /></span><script type='math/tex'>N(\hat a,\delta ) = \{ x&#124;0 < &#124;x - a&#124; < \delta\} = N(a,\delta )\backslash \{ a\} </script> <br />
<span style="color:#ff0000;">注</span>：其中， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4e11b953c374af90139d9ba8bbcf4c3d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\backslash \{ a\} " /></span><script type='math/tex'>\backslash \{ a\} </script> 表示去掉由 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 这一个数组成的数集。<br />
<span id="more-6253"></span><br />
<span style="background-color:#afeeee;">二、函数概念</span><br />
例1. 设圆的半径为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_e75c4f7ce2f1ddb8ff73ba469daeab44.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x(x/> 0)" /</span><script type='math/tex'>x(x 0)</script> ，它的面积 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c2a487b30303c6301e72c11c60c2370e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="A = \pi {x^2}" /></span><script type='math/tex'>A = \pi {x^2}</script> ，当 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_05caa54ce01728b0a9cad1d5bd8f58e5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="(0, + \infty )" /></span><script type='math/tex'>(0, + \infty )</script> 内任取一个数值（记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_a92718c8225bc2e06388bfcc3c7e03df.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\forall x \in (0, + \infty )" /></span><script type='math/tex'>\forall x \in (0, + \infty )</script> ）时，由关系式 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c2a487b30303c6301e72c11c60c2370e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="A = \pi {x^2}" /></span><script type='math/tex'>A = \pi {x^2}</script> 就可以确定A的对应数值。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e9%ab%98%e7%ad%89%e6%95%b0%e5%ad%a6%e7%ac%94%e8%ae%b02/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
<span style="background-color: rgb(0, 255, 0);">【前言】</span><br />
请看<a href="http://www.codelast.com/?p=6183" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">此文</span></a>。<br />
要查看高等数学笔记合集，请看<a href="http://www.codelast.com/?p=6363" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这里</span></a>。</p>
<p><span style="background-color: rgb(0, 255, 0);">【正文】</span><br />
<span style="color:#ff0000;">去心邻域</span>：把 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_bf08fb50b5b569418c85efdd6ffe739f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="N(a,\delta )" /></span><script type='math/tex'>N(a,\delta )</script> 的中心点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 去掉，称为点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 的去心邻域，记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_339fa6064fd5a3881d24750686ea8cb9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="N(\hat a,\delta ) = \{ x|0 < |x - a| < \delta\} = N(a,\delta )\backslash \{ a\} " /></span><script type='math/tex'>N(\hat a,\delta ) = \{ x|0 < |x - a| < \delta\} = N(a,\delta )\backslash \{ a\} </script> <br />
<span style="color:#ff0000;">注</span>：其中， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4e11b953c374af90139d9ba8bbcf4c3d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\backslash \{ a\} " /></span><script type='math/tex'>\backslash \{ a\} </script> 表示去掉由 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0cc175b9c0f1b6a831c399e269772661.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="a" /></span><script type='math/tex'>a</script> 这一个数组成的数集。<br />
<span id="more-6253"></span><br />
<span style="background-color:#afeeee;">二、函数概念</span><br />
例1. 设圆的半径为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_e75c4f7ce2f1ddb8ff73ba469daeab44.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x(x > 0)" /></span><script type='math/tex'>x(x > 0)</script> ，它的面积 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c2a487b30303c6301e72c11c60c2370e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="A = \pi {x^2}" /></span><script type='math/tex'>A = \pi {x^2}</script> ，当 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_05caa54ce01728b0a9cad1d5bd8f58e5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="(0, + \infty )" /></span><script type='math/tex'>(0, + \infty )</script> 内任取一个数值（记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_a92718c8225bc2e06388bfcc3c7e03df.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\forall x \in (0, + \infty )" /></span><script type='math/tex'>\forall x \in (0, + \infty )</script> ）时，由关系式 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_c2a487b30303c6301e72c11c60c2370e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="A = \pi {x^2}" /></span><script type='math/tex'>A = \pi {x^2}</script> 就可以确定A的对应数值。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
例2. 设有半径为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4b43b0aee35624cd95b910189b3dc231.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="r" /></span><script type='math/tex'>r</script> 的圆，作圆的内接正 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n" /></span><script type='math/tex'>n</script> 边形，每一边对应的圆心角 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_17fa0a3f9cee76d1fdbcdd0bc0bee2f5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\alpha = \frac{{2\pi }}{n}" /></span><script type='math/tex'>\alpha = \frac{{2\pi }}{n}</script> ，周长 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_24e46b552d1972209d877f0b16becd36.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{S_n} = n \cdot 2r\sin \frac{\pi }{n}" /></span><script type='math/tex'>{S_n} = n \cdot 2r\sin \frac{\pi }{n}</script> ，当边数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n" /></span><script type='math/tex'>n</script> 在自然数集 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_a8c0ec082001a1bc31b327dc2258177f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="N(n \ge 3)" /></span><script type='math/tex'>N(n \ge 3)</script> 任取一个数，通过关系式 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_efae6f1226817751518d75cf101ef04c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{S_n} = 2nr\sin \frac{\pi }{n}" /></span><script type='math/tex'>{S_n} = 2nr\sin \frac{\pi }{n}</script> 就有一个 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_230833b12826e519a7a1e5e673f5624c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{S_n}" /></span><script type='math/tex'>{S_n}</script> 对应确定数值。</p>
<div style="text-align: center;">
	<img decoding="async" alt="" src="http://www.codelast.com/wp-content/uploads/ckfinder/images/higher_mathematics_note_2_1.png" style="width: 200px; height: 236px;" /></div>
<p>
<span style="color:#ff0000;">函数定义</span>：设有数集 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_d23a4ce8bca0f4891e037439a79b45a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X,Y" /></span><script type='math/tex'>X,Y</script> ， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 是一个确定的对应法则，对 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_53207fd16e6cf990c7f977253a431a78.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\forall x \in X" /></span><script type='math/tex'>\forall x \in X</script> ，通过对应法则 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 都有唯一的 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_d44406a1dc2c9a64a39f723cefa76a83.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y \in Y" /></span><script type='math/tex'>y \in Y</script> 与 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 对应，记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_bb25e474752f18f9707f4dcfe0c687c8.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x\mathop \to \limits^f y" /></span><script type='math/tex'>x\mathop \to \limits^f y</script> ，或 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_ee01dad04908e4a766c31462453eb8c2.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f(x) = y" /></span><script type='math/tex'>f(x) = y</script> ，则称 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 为定义在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> 上的函数。<br />
其中 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> 称为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 的<span style="color:#ff0000;">定义域</span>，常记为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1823294233cee04750e2aa4fda8a8564.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{D_f}" /></span><script type='math/tex'>{D_f}</script> 。<br />
 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> &mdash;&mdash;自变量， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_57cec4137b614c87cb4e24a3d003a3e0.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="Y" /></span><script type='math/tex'>Y</script> &mdash;&mdash;因变量。<br />
当 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> 遍取 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> 中的一切数时，那么与之对应的 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y" /></span><script type='math/tex'>y</script> 值构成一个数集 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1a3c1f6b272648448b43aace95794901.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{V_f} = \{ y|y = f(x),x \in X\} " /></span><script type='math/tex'>{V_f} = \{ y|y = f(x),x \in X\} </script> ，称 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_0e79667031b7f142e335f25fda6f2ac6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{V_f}" /></span><script type='math/tex'>{V_f}</script> 为函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 的<span style="color:#ff0000;">值域</span>。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
注意：<br />
<span style="background-color:#dda0dd;">（1）</span>一个函数是由 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_f10bc3c94b77e1d6b9f98106daf335c1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x,y" /></span><script type='math/tex'>x,y</script> 的对应法则 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> 与 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 的取值范围 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_02129bb861061d1a052c592e2dc6b383.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="X" /></span><script type='math/tex'>X</script> 所确定的。把&ldquo;对应法则 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_8fa14cdd754f91cc6554c9e71929cce7.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f" /></span><script type='math/tex'>f</script> &rdquo;、&ldquo;定义域&rdquo;称为函数定义的两个要素。<br />
例如， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_6dea62e6efa4a95e79285c04720a121a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \arcsin ({x^2} + 2)" /></span><script type='math/tex'>y = \arcsin ({x^2} + 2)</script> 这个式子，由于 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_219db5f417669dc578c5ad92b531add3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x^2} + 2 > 2" /></span><script type='math/tex'>{x^2} + 2 > 2</script> ，而只有当 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_5c1063c830bfc3909e58b47ea41cabbe.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="|{x^2} + 2| \le 1" /></span><script type='math/tex'>|{x^2} + 2| \le 1</script> 时， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_6ded2bfe8f13e48d5d2db415658263b4.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\arcsin " /></span><script type='math/tex'>\arcsin </script> 才有意义，因此这个式子不构成函数关系。<br />
又例如， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_38617a4ce7d8b1ac65d24ce7d6152f61.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \ln {x^2}" /></span><script type='math/tex'>y = \ln {x^2}</script> 与 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_5d3d9386f56c35f300b9c234844d8dd8.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = 2\ln x" /></span><script type='math/tex'>y = 2\ln x</script> 不是同一个函数，因为定义域不同。而 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_38617a4ce7d8b1ac65d24ce7d6152f61.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \ln {x^2}" /></span><script type='math/tex'>y = \ln {x^2}</script> 与 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_7fb513d02c69ac07287c355ca1fea57c.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = 2\ln |x|" /></span><script type='math/tex'>y = 2\ln |x|</script> 是同一个函数，因为定义域相同。</p>
<p><span style="background-color: rgb(221, 160, 221);">（2）</span>函数的值域是定义域和对应法则共同确定的。</p>
<p><span style="background-color: rgb(221, 160, 221);">（3）</span>确定函数定义域时，注意：若函数有实际意义，需依据实际问题是否有意义来确定。<br />
若函数不表示某实际问题，则定义域为自变量所能取得的使函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd91c508f91c2c84498680bd337c1d7a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = f(x)" /></span><script type='math/tex'>y = f(x)</script> 成立的一切实数所组成的数值。<br />
函数的几何意义：设函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd91c508f91c2c84498680bd337c1d7a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = f(x)" /></span><script type='math/tex'>y = f(x)</script> 定义域为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1823294233cee04750e2aa4fda8a8564.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{D_f}" /></span><script type='math/tex'>{D_f}</script> ， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_5bc07ffd50b3efbe9c2ee502cc1512f5.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\forall x \in {D_f}" /></span><script type='math/tex'>\forall x \in {D_f}</script> ，对应函数值 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd91c508f91c2c84498680bd337c1d7a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = f(x)" /></span><script type='math/tex'>y = f(x)</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_aab047027760810a83276639203dfde1.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="XOY" /></span><script type='math/tex'>XOY</script> 平面上得到点 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_90cbc22edf225adf8a68974f51227f05.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="(x,y)" /></span><script type='math/tex'>(x,y)</script> ，当 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 遍取 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_1823294233cee04750e2aa4fda8a8564.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{D_f}" /></span><script type='math/tex'>{D_f}</script> 中一切实数时，就得到点集 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_ca428e81da3180b70336fd624c3aed30.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="P = \{ (x,y)|y = f(x),x \in {D_f}\} " /></span><script type='math/tex'>P = \{ (x,y)|y = f(x),x \in {D_f}\} </script> 。点集 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_44c29edb103a2872f519ad0c9a0fdaaa.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="P" /></span><script type='math/tex'>P</script> 称为函数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd91c508f91c2c84498680bd337c1d7a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = f(x)" /></span><script type='math/tex'>y = f(x)</script> 的图形。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="background-color:#afeeee;">三、函数的几个简单性质</span><br />
<span style="background-color:#dda0dd;">1. 函数的有界性</span><br />
若 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_f13423f1800e1e730c6a8a1b692b36d2.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\exists M > 0,\;\;s.t.\;\;|f(x)| \le M,\;x \in I" /></span><script type='math/tex'>\exists M > 0,\;\;s.t.\;\;|f(x)| \le M,\;x \in I</script> ，则称 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fd91c508f91c2c84498680bd337c1d7a.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = f(x)" /></span><script type='math/tex'>y = f(x)</script> 在区间 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dd7536794b63bf90eccfd37f9b147d7f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="I" /></span><script type='math/tex'>I</script> 上<span style="color:#ff0000;">有界</span>。否则称 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_50bbd36e1fd2333108437a2ca378be62.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f(x)" /></span><script type='math/tex'>f(x)</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dd7536794b63bf90eccfd37f9b147d7f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="I" /></span><script type='math/tex'>I</script> 上<span style="color:#ff0000;">无界</span>。<br />
注： <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_ac84d8a6f751001350a534ef3953b5d9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="s.t." /></span><script type='math/tex'>s.t.</script> 是&ldquo;使得，满足于&rdquo;的意思， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dd7536794b63bf90eccfd37f9b147d7f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="I" /></span><script type='math/tex'>I</script> 表示某个区间。<br />
例如， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_441bad5c5b571c78799e80e873cc5ab3.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \sin x" /></span><script type='math/tex'>y = \sin x</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_51476980b1b80f9b55fb8e38af4e2b82.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="I = ( - \infty , + \infty )" /></span><script type='math/tex'>I = ( - \infty , + \infty )</script> )上是有界的（因为 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_fc8c4559061601fe2a256cca50ec9690.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\;|\sin x| \le 1,\;x \in ( - \infty , + \infty )" /></span><script type='math/tex'>\;|\sin x| \le 1,\;x \in ( - \infty , + \infty )</script> ）。<br />
又如， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_6b4bddebf1b1b1077261ea14217e0155.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \frac{1}{{{x^2} + 1}}" /></span><script type='math/tex'>y = \frac{1}{{{x^2} + 1}}</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_d0b6f29f7312261c6da8700518a6a27e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="( - \infty , + \infty )" /></span><script type='math/tex'>( - \infty , + \infty )</script> 上有界。</p>
<p>对任何正数 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4839ca184f6412387dc8860bff7c5d67.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="M > 0" /></span><script type='math/tex'>M > 0</script> （无论多么大），总 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_cc63de4b9812e515cbbcf21ea312230f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\exists {x_1} \in I,\;\;s.t.\;\;|f({x_1})| > M" /></span><script type='math/tex'>\exists {x_1} \in I,\;\;s.t.\;\;|f({x_1})| > M</script> ，则称 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_50bbd36e1fd2333108437a2ca378be62.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f(x)" /></span><script type='math/tex'>f(x)</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_dd7536794b63bf90eccfd37f9b147d7f.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="I" /></span><script type='math/tex'>I</script> 上无界。<br />
例如， <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_54f0d4ac6307a2dfae5c80d83a39391d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="y = \frac{1}{x}" /></span><script type='math/tex'>y = \frac{1}{x}</script> 在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_b6dbc33006b907f2db1855810abfce98.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="(0,1)" /></span><script type='math/tex'>(0,1)</script> 内无界。<br />
证明：<br />
对给定的 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_4839ca184f6412387dc8860bff7c5d67.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="M > 0" /></span><script type='math/tex'>M > 0</script> （不妨设 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_ff1b98f02480f04cdbc23f9c9a659fd9.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="M > 1" /></span><script type='math/tex'>M > 1</script> ），无论M多么大，必存在 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_80855e47844437e098a2c62aec1ab658.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="{x_1} = \frac{1}{{2M}} \in (0,1)" /></span><script type='math/tex'>{x_1} = \frac{1}{{2M}} \in (0,1)</script> ，使 <span class='MathJax_Preview'><img src='https://www.codelast.com/wp-content/plugins/latex/cache/tex_b77e7601d705c9bb8ba5ddd8131a6dce.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="f({x_1}) = \frac{1}{{\frac{1}{{2M}}}} = 2M > M" /></span><script type='math/tex'>f({x_1}) = \frac{1}{{\frac{1}{{2M}}}} = 2M > M</script> <br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">（第2课完）</span></p>
<p><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%e9%ab%98%e7%ad%89%e6%95%b0%e5%ad%a6%e7%ac%94%e8%ae%b02/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创]两台Ubuntu计算机利用Synergy共享鼠标和键盘</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%b8%a4%e5%8f%b0ubuntu%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%a9%e7%94%a8synergy%e5%85%b1%e4%ba%ab%e9%bc%a0%e6%a0%87%e5%92%8c%e9%94%ae%e7%9b%98/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%b8%a4%e5%8f%b0ubuntu%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%a9%e7%94%a8synergy%e5%85%b1%e4%ba%ab%e9%bc%a0%e6%a0%87%e5%92%8c%e9%94%ae%e7%9b%98/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 12 Apr 2013 08:14:50 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[QuickSynergy]]></category>
		<category><![CDATA[Synergy]]></category>
		<category><![CDATA[两台Ubuntu]]></category>
		<category><![CDATA[共享键盘]]></category>
		<category><![CDATA[共享鼠标]]></category>
		<category><![CDATA[多台计算机]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=5849</guid>

					<description><![CDATA[<p>
工作时使用多台计算机的话，如果要为它们都接上鼠标、键盘可能是一件麻烦的事情：占用很多位置，而且没必要。本文介绍了如何使用<a href="http://synergy-foss.org/zh-cn/" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Synergy</span></a>程序在两台Ubuntu计算机之间共享鼠标和键盘的方法。通过此方法，你可以在鼠标移动到一个屏幕的边缘之后，自动&#8220;跳入&#8221;另一个屏幕中，并且鼠标定位在哪个屏幕中，键盘就可以在哪个屏幕中进行文字输入。<br />
<span id="more-5849"></span><br />
<span style="background-color:#00ff00;">『1』</span>安装<br />
两台Ubuntu均需要安装：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo apt-get install synergy
sudo apt-get install quicksynergy
</pre>
<p>但是要注意，如果两台Ubuntu的OS版本不同，那么可能这样装上去的Synergy，在两台机器上也是不同的版本，这可能会导致它们之间由于通信协议版本不兼容导致不能用。因此，为了保险起见，可以到Synergy的官方网站上去下载deb安装包来安装：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo dpkg -i xxx.deb
</pre>
<p>这样就可以保证两台Ubuntu上的Synergy版本一致。</p>
<p><span style="background-color:#00ff00;">『2』</span>配置server<br />
两台Ubuntu上的Synergy程序要通信，就有server和client的概念。我选择了性能较强的台式机来当server，性能较弱的笔记本来当client。<br />
在server上，你的用户的home目录下，编辑文件&#160;.synergy.conf（一开始是不存在的，创建），填入如下内容：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
section: screens
        desktop-server:
        notebook-client:
end
section: links
        notebook-client:
                right = desktop-server
        desktop-server:
                left = notebook-client

end
</pre>
<p>其中，&#8220;desktop-server&#8221;是在我的台式机（server）上，用<span style="color:#ff0000;">hostname</span>命令获取到的机器名，&#8220;notebook-client&#8221;是在我的笔记本（client）上，用<span style="color:#ff0000;">hostname</span>命令获取到的机器名。你要根据自己的情况获取到相应的名字并像上面一样填到 .synergy.conf&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%b8%a4%e5%8f%b0ubuntu%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%a9%e7%94%a8synergy%e5%85%b1%e4%ba%ab%e9%bc%a0%e6%a0%87%e5%92%8c%e9%94%ae%e7%9b%98/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
工作时使用多台计算机的话，如果要为它们都接上鼠标、键盘可能是一件麻烦的事情：占用很多位置，而且没必要。本文介绍了如何使用<a href="http://synergy-foss.org/zh-cn/" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Synergy</span></a>程序在两台Ubuntu计算机之间共享鼠标和键盘的方法。通过此方法，你可以在鼠标移动到一个屏幕的边缘之后，自动&ldquo;跳入&rdquo;另一个屏幕中，并且鼠标定位在哪个屏幕中，键盘就可以在哪个屏幕中进行文字输入。<br />
<span id="more-5849"></span><br />
<span style="background-color:#00ff00;">『1』</span>安装<br />
两台Ubuntu均需要安装：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo apt-get install synergy
sudo apt-get install quicksynergy
</pre>
<p>但是要注意，如果两台Ubuntu的OS版本不同，那么可能这样装上去的Synergy，在两台机器上也是不同的版本，这可能会导致它们之间由于通信协议版本不兼容导致不能用。因此，为了保险起见，可以到Synergy的官方网站上去下载deb安装包来安装：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
sudo dpkg -i xxx.deb
</pre>
<p>这样就可以保证两台Ubuntu上的Synergy版本一致。</p>
<p><span style="background-color:#00ff00;">『2』</span>配置server<br />
两台Ubuntu上的Synergy程序要通信，就有server和client的概念。我选择了性能较强的台式机来当server，性能较弱的笔记本来当client。<br />
在server上，你的用户的home目录下，编辑文件&nbsp;.synergy.conf（一开始是不存在的，创建），填入如下内容：</p>
<pre class="brush:plain;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
section: screens
        desktop-server:
        notebook-client:
end
section: links
        notebook-client:
                right = desktop-server
        desktop-server:
                left = notebook-client

end
</pre>
<p>其中，&ldquo;desktop-server&rdquo;是在我的台式机（server）上，用<span style="color:#ff0000;">hostname</span>命令获取到的机器名，&ldquo;notebook-client&rdquo;是在我的笔记本（client）上，用<span style="color:#ff0000;">hostname</span>命令获取到的机器名。你要根据自己的情况获取到相应的名字并像上面一样填到 .synergy.conf 文件里。<br />
在上面的配置中，&ldquo;right = desktop-server&rdquo;表示我的笔记本（client）屏幕的右边是我的台式机（server）的屏幕；同理，&ldquo;left = notebook-client&rdquo;表示我的台式机（server）的屏幕左边是我的笔记本（client）屏幕。这样设置是由我的两台计算机的屏幕摆放位置决定的。这样设置可以保证我的鼠标在移动到台式机屏幕的左边缘之后，自动&ldquo;跳入&rdquo;笔记本的屏幕中。<span style="color:#0000ff;">你需要根据自己的屏幕摆放位置来做相应的修改</span>。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
配置好之后，在server上执行如下命令来启动server端的程序：</p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
synergys
</pre>
<p><span style="background-color:#00ff00;">『3』</span>配置client<br />
在client上无需填写&nbsp;.synergy.conf 文件，只需要运行 <span style="color:#ff0000;">QuickSynergy</span> 程序进行设置，如下图所示：</p>
<div style="text-align: center;">
	<img decoding="async" alt="QuickSynergy client settings" src="http://www.codelast.com/wp-content/uploads/2013/04/quick-synergy-setting.png" style="width: 323px; height: 301px;" /></div>
<p>其中，192.168.1.65是server的地址，&ldquo;notebook-client&rdquo;是在client上用hostname命令取到的主机名。<br />
设置好之后点击&ldquo;Execute&rdquo;就可以启动客户端了。启动之后，鼠标、键盘就可以共享了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
注意，如果在第『1』步中，你是通过deb包的方式来安装的Synergy，那么这里就没有quicksynergy程序，此时，在client端启动程序，只需简单地输入&ldquo;synergy&rdquo;命令，会弹出一个比上图稍微复杂一点的对话框，但里面的设置也是比较容易看懂的，这里就不粘上来了。</p>
<p><span style="background-color: rgb(0, 255, 0);">『4』</span><span style="font-family: Ubuntu;">client连接不上server的问题<br />
如果你确保设置正确了，却无法让client连接上server，可以看一下server端的系统日志：</span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
tail -f /var/log/syslog
</pre>
<p><span style="font-family: Ubuntu;">如果里面有类似于下面这样的错误提示：</span></p>
<blockquote>
<p>
		NOTE: new client disconnected#012#011/build/buildd/synergy-1.3.8/src/lib/server/CClientProxyUnknown.cpp,282</p>
</blockquote>
<p><span style="font-family: Ubuntu;">那么有可能是client端与server端的软件版本不匹配造成的。<br />
例如，我在发生连接问题的两台Ubuntu计算机上分别用如下命令查看Synergy的版本：</span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
synergys --version
</pre>
<p><span style="font-family: Ubuntu;">结果，server的版本是1.3.8，而client的版本是1.4.10。<br />
这就有问题了，因为不同的版本使用的协议可能是不兼容的，所以client无法与server通信，因此连不上server。所以，你可以到Synergy的官方网站上下载版本相同的client和server的安装包来用，就会发现问题解决了。</span><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
<span style="font-family: Ubuntu;">另外，如果client启用了SSL加密功能，而server端启动的时候没有启用SSL，也会造成client连接不上server，在client端的错误日志中会看到和SSL相关的错误信息（例如含有关键字</span><span style="color:#b22222;">SSL23_GET_SERVER_HELLO</span>之类的）<span style="font-family: Ubuntu;">。<br />
此时，你需要kill掉server端的服务程序synergys，然后启用SSL来启动服务：</span></p>
<pre class="brush:shell;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
synergys --enable-crypto
</pre>
<p><font face="Ubuntu">然后client端重新连接就OK了。</font></p>
<p><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>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushShell.js"></script>
<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushPlain.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e4%b8%a4%e5%8f%b0ubuntu%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%a9%e7%94%a8synergy%e5%85%b1%e4%ba%ab%e9%bc%a0%e6%a0%87%e5%92%8c%e9%94%ae%e7%9b%98/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>[原创]如何添加一个文件/目录到IntelliJ项目的classpath中</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 03 Mar 2013 13:10:40 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[classpath]]></category>
		<category><![CDATA[IntelliJ]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[添加到classpath]]></category>
		<guid isPermaLink="false">http://www.codelast.com/?p=5744</guid>

					<description><![CDATA[<p>
以下内容的背景：IntelliJ，Java项目。<br />
在单元测试中，我们经常会使用与生产环境里不同的一些配置文件来为提供参数，而你的程序又是以类似下面的方法来读取配置文件：</p>
<pre class="brush:java;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
String configFileName = &#34;config.properties&#34;;
Properties properties = new Properties();
properties.load(MyClass.class.getClassLoader().getResourceAsStream(configFileName));
</pre>
<p>上面的代码中仅使用了配置文件名，而不是其完整路径，这就导致了可能在IntelliJ中运行一个单独的单元测试的时候，找不到该配置文件，因为你只提供文件名的话，该文件必须要在classpath中，否则是找不到它的。<br />
<span id="more-5744"></span><br />
所以，我们可以把该配置文件所在的目录添加到IntelliJ项目里的classpath中，让它可以在运行单元测试的时候找得到。方法如下（一图胜千言，直接看下面的演示图就明白了）：<br />
<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
点击菜单File&#8594;Project Structure，进入&#8220;Project Structure&#8221;对话框，点击左侧的&#8220;Modules&#8221;，然后点击中部的&#8220;Dependencies&#8221;tab，然后再点击右部的&#8220;+&#8221;号添加你指定的目录，这里要注意了，在弹出的&#8220;Attach Files&#8221;对话框中，你必须要选择&#8220;classes&#8221;（如图所示）。最后，把目录添加进来之后，再把它们对应的&#8220;Scope&#8221;设置为&#8220;Test&#8221;，表示在测试中会依赖这个目录，即可。<br />
<img decoding="async" alt="add a file or directory to the classpath of an IntelliJ Java project" src="http://www.codelast.com/wp-content/uploads/2013/03/project_structure_with_demo_final.png" style="width: 576px; height: 218px; " /><br />
<strong><span style="color:#ff0000;">图片可保存下来放大查看。</span></strong></p>
<p>以上方法在IntelliJ 12.0.4中亲测通过，对于其他版本的IntelliJ也应该类似。</p>
<p><span style="background-color:#00ff00;">【补充】</span><br />
12.1.4版的IntelliJ与上面的图略有不同。在点击了&#8220;+&#8221;号之后，会弹出一个菜单：</p>
<div style="text-align: center;">
	<img decoding="async" alt="add menu" src="http://www.codelast.com/wp-content/uploads/2013/03/add_menu.png" style="width: 158px; height: 89px;" /></div>
<p>选择&#8220;Jars or directories...&#8221;，然后会弹出对话框让你选择目录或文件，选择好之后，和上面一样，要选择&#8220;classes&#8221;，后面的操作也一样了。</p>
<p><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;" /></p>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']</script>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
以下内容的背景：IntelliJ，Java项目。<br />
在单元测试中，我们经常会使用与生产环境里不同的一些配置文件来为提供参数，而你的程序又是以类似下面的方法来读取配置文件：</p>
<pre class="brush:java;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">
String configFileName = &quot;config.properties&quot;;
Properties properties = new Properties();
properties.load(MyClass.class.getClassLoader().getResourceAsStream(configFileName));
</pre>
<p>上面的代码中仅使用了配置文件名，而不是其完整路径，这就导致了可能在IntelliJ中运行一个单独的单元测试的时候，找不到该配置文件，因为你只提供文件名的话，该文件必须要在classpath中，否则是找不到它的。<br />
<span id="more-5744"></span><br />
所以，我们可以把该配置文件所在的目录添加到IntelliJ项目里的classpath中，让它可以在运行单元测试的时候找得到。方法如下（一图胜千言，直接看下面的演示图就明白了）：<br />
<span style="color: rgb(255, 255, 255); ">文章来源：</span><a href="http://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255); ">http://www.codelast.com/</span></a><br />
点击菜单File&rarr;Project Structure，进入&ldquo;Project Structure&rdquo;对话框，点击左侧的&ldquo;Modules&rdquo;，然后点击中部的&ldquo;Dependencies&rdquo;tab，然后再点击右部的&ldquo;+&rdquo;号添加你指定的目录，这里要注意了，在弹出的&ldquo;Attach Files&rdquo;对话框中，你必须要选择&ldquo;classes&rdquo;（如图所示）。最后，把目录添加进来之后，再把它们对应的&ldquo;Scope&rdquo;设置为&ldquo;Test&rdquo;，表示在测试中会依赖这个目录，即可。<br />
<img decoding="async" alt="add a file or directory to the classpath of an IntelliJ Java project" src="http://www.codelast.com/wp-content/uploads/2013/03/project_structure_with_demo_final.png" style="width: 576px; height: 218px; " /><br />
<strong><span style="color:#ff0000;">图片可保存下来放大查看。</span></strong></p>
<p>以上方法在IntelliJ 12.0.4中亲测通过，对于其他版本的IntelliJ也应该类似。</p>
<p><span style="background-color:#00ff00;">【补充】</span><br />
12.1.4版的IntelliJ与上面的图略有不同。在点击了&ldquo;+&rdquo;号之后，会弹出一个菜单：</p>
<div style="text-align: center;">
	<img decoding="async" alt="add menu" src="http://www.codelast.com/wp-content/uploads/2013/03/add_menu.png" style="width: 158px; height: 89px;" /></div>
<p>选择&ldquo;Jars or directories...&rdquo;，然后会弹出对话框让你选择目录或文件，选择好之后，和上面一样，要选择&ldquo;classes&rdquo;，后面的操作也一样了。</p>
<p><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>

			<!--[syntaxhighlighter]-->
			<!--代码高亮，请勿编辑-->
			<script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript" src="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js"></script>

			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shCoreCk.css" />
			<link type="text/css" rel="stylesheet" href="https://www.codelast.com/wp-content/plugins/ck-and-syntaxhighlighter/syntaxhighlighter/styles/shThemeCk.css" />
			<script type="text/javascript">
			SyntaxHighlighter.defaults['class-name']	= '';
			SyntaxHighlighter.defaults['smart-tabs']	= true;
			SyntaxHighlighter.defaults['tab-size']		= 2;
			SyntaxHighlighter.defaults['gutter']		= true;
			SyntaxHighlighter.defaults['quick-code']	= true;
			SyntaxHighlighter.defaults['collapse'] 		= false;
			SyntaxHighlighter.defaults['auto-links']	= true;
			SyntaxHighlighter.defaults['toolbar']		= true;
			SyntaxHighlighter.all();
			</script>
			<!--[/syntaxhighlighter]-->]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e5%88%b0intellij%e9%a1%b9%e7%9b%ae%e7%9a%84classpath%e4%b8%ad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
