<div class="note"><div class="post"><div class="article"><h1 class="title">tensorflow学习笔记系列(三):tensorflow入门与基本使用</h1><!-- 作者区域 --><div class="author"><a class="avatar" href="/u/b43a53b0a757"><img src="//upload.jianshu.io/users/upload_avatars/2359267/76571136b25e.jpeg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96" alt="96">
</a>          <div class="info"><span class="name"><a href="/u/b43a53b0a757">mac在路上</a></span><!-- 关注用户按钮 --><a class="btn btn-success follow"><i class="iconfont ic-follow"></i><span>关注</span></a><!-- 文章数据信息 --><div class="meta"><!-- 如果文章更新时间大于发布时间,那么使用 tooltip 显示更新时间 --><span class="publish-time" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="最后编辑于 2017.12.06 02:47">2017.03.09 15:40*</span><span class="wordage">字数 3163</span><span class="views-count">阅读 9234</span><span class="comments-count">评论 2</span><span class="likes-count">喜欢 14</span></div></div><!-- 如果是当前作者,加入编辑按钮 --></div><!-- 文章内容 --><div data-note-content="" class="show-content"><div class="show-content-free"><p><strong><em><u>版权所有,转载请注明出处</u></em></strong></p>
<hr>
<p>其它相关文章:<br>
<a href="https://www.jianshu.com/p/1d63f25b476a" target="_blank">tensorflow学习笔记系列(一):前言</a><br>
<a href="https://www.jianshu.com/p/4b0992253626" target="_blank">tensorflow学习笔记系列(二):tensorflow简介与安装</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(四):tensorflow实现自动编码机</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(五):tensorflow实现多层感知机</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(六):tensorflow实现卷积神经网络</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(七):神经网络的一些理论知识</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(八):TensorBoard介绍</a><br>
<a href="" target="_blank">tensorflow学习笔记系列(九):tensorflow源码解析</a></p>
<ul>
<li><strong><u>说明:</u></strong></li>
<li>目前已完成(一)~(三)</li>
<li>该内容为本人学习tensorflow过程中的笔记,皆为个人理解,难免会存在各种问题,有不当之处请大家批评指正!</li>
</ul>
<hr>
<p>基本上每一个语言或者工具都有自己的“hello world” demo,那么学习它们一般都会从这个“hello world”开始。今天我们就来看看tensorflow的“hello world”(非官网)。<br>
在开始编写“hello world”之前我们先看看tensorflow的编程模型。</p>
<h1>一. tensorflow编程模型简介</h1>
<p>这部分的一个很好的教程是官网上的<a href="https://link.jianshu.com?t=https://www.tensorflow.org/versions/r0.10/get_started/basic_usage#basic-usage" target="_blank" rel="nofollow">Basic Usage</a>,讲解的还是很清晰的。</p>
<p>Tensorflow中的计算可以表示为一个有向图(directed graph),或称计算图(computation graph),其中每一个运算操作将作为一个节点(node),节点与节点之间的连接成为边(edge),而在计算图的边中流动(flow)的数据被称为张量(tensor),所以形象的看整个操作就好像数据(tensor)在计算图(computation graphy)中沿着边(edge)流过(flow)一个个节点(node),这就是tensorflow名字的由来的。</p>
<div class="image-package">
<div class="image-container" style="max-width: 252px; max-height: 448px; background-color: transparent;">
<div class="image-container-fill" style="padding-bottom: 177.78%;"></div>
<div class="image-view" data-width="252" data-height="448"><img data-original-src="//upload-images.jianshu.io/upload_images/2359267-a48bb63667981b9a.gif" data-original-width="252" data-original-height="448" data-original-format="image/gif" data-original-filesize="382923" style="cursor: zoom-in;" class="" src="//upload-images.jianshu.io/upload_images/2359267-a48bb63667981b9a.gif?imageMogr2/auto-orient/strip%7CimageView2/2/w/252"></div>
</div>
<div class="image-caption"></div>
</div>
<p>计算图中的每个节点可以有任意多个输入和任意多个输出,每个节点描述了一种运算操作(operation, op),节点可以算作运算操作的实例化(instance)。计算图描述了数据的计算流程,它也负责维护和更新状态,用户可以对计算图的分支进行条件控制或循环操作。用户可以使用pyton、C++、Go、Java等语言设计计算图。tensorflow通过计算图将所有的运算操作全部运行在python外面,比如通过c++运行在cpu或通过cuda运行在gpu 上,所以实际上python只是一种接口,真正的核心计算过程还是在底层采用c++或cuda在cpu或gpu上运行。</p>
<p>一个 TensorFlow图描述了计算的过程. 为了进行计算, 图必须在会话(session)里被启动. 会话将图的op分发到诸如CPU或GPU之的备上, 同时提供执行op的方法. 这些方法执行后, 将产生的tensor返回. 在Python语言中, 返回的tensor是numpy ndarray对象; 在C和C++语言中, 返回的tensor是tensorflow::Tensor实例。</p>
<p>从上面的描述中我们可以看到,tensorflow的几个比较重要的概念:tensor, computation graphy, node, session。正如前面所说,整个操作就好像数据(tensor)在计算图(computation graphy)中沿着边(edge)流过(flow)一个个节点(node),然后通过会话(session)启动计算。所以简单来说,要完成这整个过程,我们需要的东西是要定义数据、计算图和计算图上的节点,以及启动计算的会话。所以在实际使用中我们要做的大部分工作应该就是定义这些内容了。</p>
<h1>二. tensorflow基本使用</h1>
<p>正如官方教程里所说:</p>
<blockquote>
<p>To use TensorFlow you need to understand how TensorFlow:</p>
</blockquote>
<ul>
<li>Represents computations as graphs.</li>
<li>Executes graphs in the context of Sessions.</li>
<li>Represents data as tensors.</li>
<li>Maintains state with Variables.</li>
<li>Uses feeds and fetches to get data into and out of arbitrary operations.</li>
</ul>
<p>我们只有理解了这些概念,明白它们分别是做什么的,才能掌握tensorflow的使用方法。下面简单介绍下这些概念及使用。</p>
<ul>
<li>计算图(computation graphy)<br>
计算图是由一个个节点和连接各个节点的边组成,因此要定义一个计算图,只需要定义好各个节点以及节点的输入输出(对应计算图的边)。节点代表各种操作,如加法、乘法、卷积运算等等,输入输出主要是各种数据(tensor)。下面是一个简单的计算图定义方法示例(来自<a href="https://link.jianshu.com?t=https://www.tensorflow.org/versions/r0.10/get_started/basic_usage#basic-usage" target="_blank" rel="nofollow">官网</a>):</li>
</ul>
<pre class="hljs python"><code class="python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf<span class="hljs-comment"># Create a Constant op that produces a 1x2 matrix.  The op is</span>
<span class="hljs-comment"># added as a node to the default graph.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># The value returned by the constructor represents the output</span>
<span class="hljs-comment"># of the Constant op.</span>
matrix1 = tf.constant([[<span class="hljs-number">3.</span>, <span class="hljs-number">3.</span>]])<span class="hljs-comment"># Create another Constant that produces a 2x1 matrix.</span>
matrix2 = tf.constant([[<span class="hljs-number">2.</span>],[<span class="hljs-number">2.</span>]])<span class="hljs-comment"># Create a Matmul op that takes 'matrix1' and 'matrix2' as inputs.</span>
<span class="hljs-comment"># The returned value, 'product', represents the result of the matrix</span>
<span class="hljs-comment"># multiplication.</span>
product = tf.matmul(matrix1, matrix2)
</code></pre>
<p>当然,我们也可以添加更多更复杂的操作(operation)的节点(node)到计算图(computation graphy)中,如果增加一些卷积网络节点、全连接网络节点等等就可以组建一个神经网络计算图了。</p>
<ul>
<li>节点(node)<br>
计算图中的每个节点可以有任意多个输入和任意多个输出,每个节点描述了一种运算操作(operation, op),节点可以算作运算操作的实例化(instance)。一种运算操作代表了一种类型的抽象运算,比如矩阵乘法货响亮加法。tensorflow内建了很多种运算操作,如下表所示:</li>
</ul>
<table>
<thead>
<tr>
<th>类型</th>
<th style="text-align:left">示例</th>
</tr>
</thead>
<tbody>
<tr>
<td>标量运算</td>
<td style="text-align:left">Add、Sub、Mul、Div、Exp、Log、Greater、Less、Equal</td>
</tr>
<tr>
<td>向量运算</td>
<td style="text-align:left">Concat、Slice、Splot、Constant、Rank、Shape、Shuffle</td>
</tr>
<tr>
<td>矩阵运算</td>
<td style="text-align:left">Matmul、MatrixInverse、MatrixDeterminant</td>
</tr>
<tr>
<td>带状态的运算</td>
<td style="text-align:left">Variable、Assign、AssignAdd</td>
</tr>
<tr>
<td>神经网络组件</td>
<td style="text-align:left">SoftMax、Sigmoid、ReLU、Convolution2D、MaxPooling</td>
</tr>
<tr>
<td>存储、恢复</td>
<td style="text-align:left">Save、Restore</td>
</tr>
<tr>
<td>队列及同步运算</td>
<td style="text-align:left">Enqueue、Dequeue、MutexAcquire、MutexRelease</td>
</tr>
<tr>
<td>控制流</td>
<td style="text-align:left">Merge、Switch、Enter、Leave、NextIteration</td>
</tr>
</tbody>
</table>
<p>在tensorflow中,也可以通过注册机制加入新的运算操作或者运算核,这和torch上的注册机制类似。</p>
<ul>
<li>会话(session)<br>
正如我们前面所说,计算图里描述的计算并没有真正执行,只是进行了定义和描述,要实际执行我们就需要在会话(session)里被启动. 这时session才会将计算图上的节点操作op分发到诸如CPU或GPU之类的设备上, 同时提供执行op的方法. 这些方法执行后,将产生的tensor返回.<br>
要启动计算图,我们收下需要定义一个session对象:</li>
</ul>
<pre class="hljs undefined"><code>sess = tf.Session()
</code></pre>
<p>启动操作,最简单的就是调用函数run:</p>
<pre class="hljs undefined"><code>result = sess.run(product)
</code></pre>
<p>tensorflow还支持分布式session,将计算图布置到多个机器上进行计算。由于我这边不具备该环境,就不介绍这部分内容了。<br>
另外tensorflow还支持交互环境下采用<code>InteractiveSession</code>定义一个交互session,然后所有的操作都默认在该session上运行,可以直接调用<code>Tensor.eval()</code>和<code>Operation.run()</code>两个方法,如:</p>
<pre class="hljs php"><code class="php"><span class="hljs-comment"># Enter an interactive TensorFlow Session.</span>
import tensorflow <span class="hljs-keyword">as</span> tf
sess = tf.InteractiveSession()x = tf.Variable([<span class="hljs-number">1.0</span>, <span class="hljs-number">2.0</span>])
a = tf.constant([<span class="hljs-number">3.0</span>, <span class="hljs-number">3.0</span>])<span class="hljs-comment"># Initialize 'x' using the run() method of its initializer op.</span>
x.initializer.run()<span class="hljs-comment"># Add an op to subtract 'a' from 'x'.  Run it and print the result</span>
sub = tf.sub(x, a)
<span class="hljs-keyword">print</span>(sub.<span class="hljs-keyword">eval</span>())
<span class="hljs-comment"># ==> [-2. -1.]</span><span class="hljs-comment"># Close the Session when we're done.</span>
sess.close()
</code></pre>
<ul>
<li>数据(tensor)<br>
TensorFlow程序使用tensor数据结构来代表所有的数据, 计算图中的节点间传递的数据都是tensor. 你可以把TensorFlow tensor看作是一个n维的数组或列表. 一个 tensor包含一个静态类型rank, 和一个shape。</li>
<li>变量(Variable)<br>
在tensorflow里有一类数据比较特殊,那就是我们需要在整个计算图执行过程中需要保存的状态。比如我们在进行神经网络训练时要时刻保存并更新的网络参数,这时我们就需要用到Varibale来保存这些参数。其实,我们在前面的示例中已经用到了变量的定义了,它的定义关键字为<code>Variable</code>,如上面的<code>x = tf.Variable([1.0, 2.0])</code>。</li>
<li>feed & fetch<br>
我们都知道,进行机器学习或者神经网络训练时,都需要大量的训练数据。细心的朋友可能注意到,我们前面一直没讲到训练数据怎么定义,怎么输入到网络里。实际上,tensorflow提供了一个feed机制来将tensor直接放置到计算图的任意节点操作上去。“feed”这个词用的很形象啊,就像我们在上课学习时,老师拿课本里的各种例子、习题往我们脑子里喂。那么,这个利用这个feed机制我们就可以把训练数据“喂”到计算图的输入中去。一般我们采用placeholder来指定一个feed操作,这个placeholder就像是一个容器一样来接收训练数据,然后在最终进行计算时只需要用placehoder里的数据替换计算图的输入量就可以了。一个简单的例子:</li>
</ul>
<pre class="hljs python"><code class="python">input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.mul(input1, input2)<span class="hljs-keyword">with</span> tf.Session() <span class="hljs-keyword">as</span> sess:print(sess.run([output], feed_dict={input1:[<span class="hljs-number">7.</span>], input2:[<span class="hljs-number">2.</span>]}))
</code></pre>
<p>采用两个placeholder操作来定义两个输入,在后面的see.run()里采用feed_dict替换成真正的训练数据,feed_dict里的才是真正的数据。一般情况,placeholder和feed_dict是搭配使用的。<br>
fetch,正如其字面意思,就是取回数据的意思。我们将计算图部署到session上进行计算后,需要将计算结果取回,这就是一个fetch。下面是取回多个tensor的例子:</p>
<pre class="hljs python"><code class="python">input1 = tf.constant(<span class="hljs-number">3.0</span>)
input2 = tf.constant(<span class="hljs-number">2.0</span>)
input3 = tf.constant(<span class="hljs-number">5.0</span>)
intermed = tf.add(input2, input3)
mul = tf.mul(input1, intermed)
<span class="hljs-keyword">with</span> tf.Session() <span class="hljs-keyword">as</span> sess:result = sess.run([mul, intermed])<span class="hljs-keyword">print</span> result
</code></pre>
<p>上面就是tensorflow编程模型的一些基本概念和内容。通过上面的介绍,我们可以用一句话来总结tensorflow的一个工作流程:</p>
<p>那么我们也可以简单总结出tensorflow编程的一个基本步骤:</p>
<ol>
<li>定义数据</li>
<li>定义计算图与变量</li>
<li>定义会话</li>
<li>进行计算</li>
</ol>
<h1>三. 用tensorflow搭建神经网络“hello world”</h1>
<p>按照我们上一节介绍的tensorflow编程的基本步骤,我们来搭建我们的第一个神经网络——基于mnist数据集的手写数字识别,即基于图片的10分类问题。<br>
此部分可以参考官网教程<a href="https://link.jianshu.com?t=https://www.tensorflow.org/versions/r0.12/tutorials/mnist/beginners/index.html" target="_blank" rel="nofollow">MNIST For ML Beginners</a>。<br>
MNIST是一个简单的机器视觉数据集,如下图所示,它有几万张28×28像素的手写数字组成,这些图片只包含灰度信息,我们的任务就是对这些手写数字进行分类,转成0~9一共10类。<br>
</p><div class="image-package">
<div class="image-container" style="max-width: 636px; max-height: 159px;">
<div class="image-container-fill" style="padding-bottom: 25.0%;"></div>
<div class="image-view" data-width="636" data-height="159"><img data-original-src="//upload-images.jianshu.io/upload_images/2359267-e23300ae69bf6cf9.png" data-original-width="636" data-original-height="159" data-original-format="image/png" data-original-filesize="21268" style="cursor: zoom-in;" class="image-loading"></div>
</div>
<div class="image-caption"></div>
</div><p></p>
<p><strong>1.定义数据</strong><br>
在神经网络里我们需要定义的数据就是输入训练/测试数据,而变量用来存储网络模型里的各种参数。如:</p>
<pre class="hljs python"><code class="python"><span class="hljs-comment"># 输入数据(包括训练数据和测试数据)</span>
x = tf.placeholder( tf.float32, [<span class="hljs-keyword">None</span>, <span class="hljs-number">784</span>] )
y_ = tf.placeholder( tf.float32, [<span class="hljs-keyword">None</span>, <span class="hljs-number">10</span>] )
</code></pre>
<p>这里我们把图片的28<em>28个像素展开成一维列向量(28</em>28-784)<br>
<strong>2.定义计算图与变量</strong><br>
对于神经网络来说,涉及到的操作主要有三部分:网络模型定义,损失函数定义、训练/优化方法定义。那么我们的计算图基本也由这三部分的定义组成。(当然还可能包括其它部分,如输入数据初始化操作,网络参数初始化等等,这里我们不讨论)</p>
<ul>
<li>网络模型定义<br>
这里我们定义一个最简单的单层全连接网络,计算公式为:<code>y=Wx+b</code>,然后利用softmax来计算预测概率,预测概率最大的对应预测的分类。我需要定义两个变量来保存网络参数<code>W</code>和<code>b</code>的状态。<br>
<div class="image-package">
<div class="image-container" style="max-width: 700px; max-height: 279px;">
<div class="image-container-fill" style="padding-bottom: 39.94%;"></div>
<div class="image-view" data-width="2907" data-height="1161"><img data-original-src="//upload-images.jianshu.io/upload_images/2359267-4361a7bbfea07c3d.png" data-original-width="2907" data-original-height="1161" data-original-format="image/png" data-original-filesize="421224" style="cursor: zoom-in;" class="image-loading"></div>
</div>
<div class="image-caption"></div>
</div>
</li>
</ul>
<pre class="hljs undefined"><code>W = tf.Variable( tf.zeros([784,10]) )
b = tf.Variable( tf.zeros([10]) )
y = tf.nn.softmax( tf.matmul(x,W) + b )
</code></pre>
<ul>
<li>损失函数定义<br>
采用cross-entropy作为损失函数,它的公式为:$H_{y'}\left(y\right)=-\underset{i}{{\textstyle \sum}}y'<em>{i}\log\left(y</em>{i}\right)$。(才发现简书竟然不支持Latex,尴尬。。。)<br>
<div class="image-package">
<div class="image-container" style="max-width: 223px; max-height: 54px;">
<div class="image-container-fill" style="padding-bottom: 24.22%;"></div>
<div class="image-view" data-width="223" data-height="54"><img data-original-src="//upload-images.jianshu.io/upload_images/2359267-215684d665a71a06.png" data-original-width="223" data-original-height="54" data-original-format="image/png" data-original-filesize="3569" style="cursor: zoom-in;" class="image-loading"></div>
</div>
<div class="image-caption"></div>
</div>
</li>
</ul>
<pre class="hljs cpp"><code class="cpp">cross_entropy = tf.reduce_mean( -tf.reduce_sum( y_*tf.<span class="hljs-built_in">log</span>(y), reduction_indices=[<span class="hljs-number">1</span>] ) )
</code></pre>
<ul>
<li>训练/优化方法定义<br>
神经网络常采用SGD(Stochastic Gradient Descent)进行网络的优化训练。tensorflow会自动根据前面定义的计算图进行forward和backward计算并更新参数。</li>
</ul>
<pre class="hljs undefined"><code>train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
</code></pre>
<p><strong>3.定义会话</strong><br>
按照前面的方法,定义一个session即可。但是还要记住对所有的变量进行全局初始化。</p>
<pre class="hljs bash"><code class="bash">sess = tf.InteractiveSession()
tf.global_variables_initializer().run() <span class="hljs-comment">#由于是InteractiveSession可以直接run</span>
</code></pre>
<p>或者</p>
<pre class="hljs undefined"><code>sess = tf.Session()
init = tf.global_variables_initializer()
sess.run()
</code></pre>
<p><strong>4.进行计算</strong><br>
对于神经网络来说,就是要开始迭代进行训练和评估,降低损失函数。</p>
<pre class="hljs bash"><code class="bash"><span class="hljs-comment"># training</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(10000):batch_xs, batch_ys = mnist.train.next_batch(100)train_step.run( {x:batch_xs, y_:batch_ys} ) <span class="hljs-comment">#InteractiveSession</span>
<span class="hljs-comment">#       sess.run(train_step, feed_dict={x:batch_xs, y_:batch_ys}) #非InteractiveSession</span>
<span class="hljs-comment"># eval</span>
correct_prediction = tf.equal( tf.argmax(y,1), tf.argmax(y_,1) )
accuracy = tf.reduce_mean( tf.cast(correct_prediction, tf.float32) )
<span class="hljs-built_in">print</span>(accuracy.eval( {x:mnist.test.images, y_:mnist.test.labels} ))  <span class="hljs-comment">#InteractiveSession</span>
<span class="hljs-built_in">print</span>(sess.run(accuracy, feed_dict={x:mnist.test.images, y_:mnist.test.labels})<span class="hljs-comment">#非InteractiveSession</span>
</code></pre>
<p>以上就是整个神经网络的搭建过程。这里只采用的单层全连接网络,但是准确率依然达到了92%左右,如果我们采用卷积神经网络等更复杂的网络,可以将准确率提高到99%。<br>
以上只是搭建一个神经网络的基本框架,当然实际中还是数据预处理、参数初始化、超参数设置等问题,这些就需要在实际使用过程中慢慢学习了。<br>
以下是该网络的全部代码:</p>
<pre class="hljs python"><code class="python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> tensorflow.examples.tutorials.mnist <span class="hljs-keyword">import</span> input_data
mnist = input_data.read_data_sets(<span class="hljs-string">"MNIST_data/"</span>,one_hot=<span class="hljs-keyword">True</span>)x = tf.placeholder( tf.float32, [<span class="hljs-keyword">None</span>, <span class="hljs-number">784</span>] )
y_ = tf.placeholder( tf.float32, [<span class="hljs-keyword">None</span>, <span class="hljs-number">10</span>] )W = tf.Variable( tf.zeros([<span class="hljs-number">784</span>,<span class="hljs-number">10</span>]) )
b = tf.Variable( tf.zeros([<span class="hljs-number">10</span>]) )
y = tf.nn.softmax( tf.matmul(x,W) + b )cross_entropy = tf.reduce_mean( -tf.reduce_sum( y_*tf.log(y), reduction_indices=[<span class="hljs-number">1</span>] ) )train_step = tf.train.GradientDescentOptimizer(<span class="hljs-number">0.5</span>).minimize(cross_entropy)session = tf.InteractiveSession()
tf.global_variables_initializer().run()<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">1000</span>):batch_xs, batch_ys = mnist.train.next_batch(<span class="hljs-number">100</span>)train_step.run( {x:batch_xs, y_:batch_ys} )<span class="hljs-comment">#       print(i)</span>correct_prediction = tf.equal( tf.argmax(y,<span class="hljs-number">1</span>), tf.argmax(y_,<span class="hljs-number">1</span>) )
accuracy = tf.reduce_mean( tf.cast(correct_prediction, tf.float32) )
print(accuracy.eval( {x:mnist.test.images, y_:mnist.test.labels} )) </code></pre>
<p>大家也可以在<a href="" target="_blank">tensorflow.examples.tutorials</a>下找到官方的示例代码,或者我本人的<a href="https://link.jianshu.com?t=https://github.com/SSSuperMac/tensorflow-study" target="_blank" rel="nofollow">github</a>上查看</p>
<p><strong><div align = center>-END-</div></strong></p>
<hr>
<p><strong><em><u>版权所有,转载请注明出处</u></em></strong></p></div></div></div><!-- 如果是付费文章,未购买,则显示购买按钮 --><!-- 连载目录项 --><!-- 如果是付费文章 --><!-- 如果是付费连载,已购买,且作者允许赞赏,则显示付费信息和赞赏 --><div id="free-reward-panel" class="support-author"><p>小礼物走一走,来简书关注我</p> <div class="btn btn-pay">赞赏支持</div> <div class="supporter"><ul class="support-list"></ul> <!----></div> <!----> <!----></div><div class="show-foot"><a class="notebook" href="/nb/4870754"><i class="iconfont ic-search-notebook"></i><span>深度学习</span>
</a>        <div class="copyright" data-toggle="tooltip" data-html="true" data-original-title="转载请联系作者获得授权,并标注“简书作者”。">© 著作权归作者所有</div><div class="modal-wrap" data-report-note=""><a id="report-modal">举报文章</a></div></div><!-- 文章底部作者信息 --><div class="follow-detail"><div class="info"><a class="avatar" href="/u/b43a53b0a757"><img src="//upload.jianshu.io/users/upload_avatars/2359267/76571136b25e.jpeg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96" alt="96">
</a>            <a class="btn btn-success follow"><i class="iconfont ic-follow"></i><span>关注</span></a><a class="title" href="/u/b43a53b0a757">mac在路上</a><p>写了 35508 字,被 229 人关注,获得了 139 个喜欢</p></div><div class="signature">在路上……</div></div><div class="meta-bottom"><div data-v-6ddd02c6="" class="like"><div data-v-6ddd02c6="" class="btn like-group"><div data-v-6ddd02c6="" class="btn-like"><a data-v-6ddd02c6="">喜欢</a></div> <div data-v-6ddd02c6="" class="modal-wrap"><a data-v-6ddd02c6="">14</a></div></div> <!----></div><div class="share-group"><a class="share-circle" data-action="weixin-share" data-toggle="tooltip" data-original-title="分享到微信"><i class="iconfont ic-wechat"></i></a><a class="share-circle" data-action="weibo-share" data-toggle="tooltip" href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=1881139527',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','', '推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》( 分享自 @简书 )','https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=weibo','页面编码gb2312|utf-8默认gb2312'));" data-original-title="分享到微博"><i class="iconfont ic-weibo"></i></a><a class="share-circle" data-toggle="tooltip" href="http://cwb.assets.jianshu.io/notes/images/9963920/weibo/image_759987196792.jpg" target="_blank" data-original-title="下载长微博图片"><i class="iconfont ic-picture"></i></a><a class="share-circle more-share" tabindex="0" data-toggle="popover" data-placement="top" data-html="true" data-trigger="focus" href="javascript:void(0);" data-content="<ul class="share-list"><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=qzone')+'&title='+e('推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》'),x=function(){if(!window.open(r,'qzone','toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-zone"></i><span>分享到QQ空间</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://twitter.com/share?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=twitter')+'&text='+e('推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》( 分享自 @jianshucom )')+'&related='+e('jianshucom'),x=function(){if(!window.open(r,'twitter','toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-twitter"></i><span>分享到Twitter</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://www.facebook.com/dialog/share?app_id=483126645039390&display=popup&href=https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=facebook',x=function(){if(!window.open(r,'facebook','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-facebook"></i><span>分享到Facebook</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://plus.google.com/share?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=google_plus'),x=function(){if(!window.open(r,'google_plus','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class="social-icon-sprite social-icon-google"></i><span>分享到Google+</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=douban')+'&title='+e('tensorflow学习笔记系列(三):tensorflow入门与基本使用')+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()"><i class="social-icon-sprite social-icon-douban"></i><span>分享到豆瓣</span></a></li></ul>" data-original-title="" title="">更多分享</a></div></div><a id="web-note-ad-1" target="_blank" href="/apps/download?utm_source=nbc"><img src="//cdn2.jianshu.io/assets/web/web-note-ad-1-10f08e404d3887d2d45a4bc8f1831403.png" alt="Web note ad 1"></a><div id="vue_comment"></div></div><div class="side-tool"><ul><li data-placement="left" data-toggle="tooltip" data-container="body" data-original-title="回到顶部" style="display: none;"><a class="function-button"><i class="iconfont ic-backtop"></i></a></li> <!----> <!----> <!----> <li data-placement="left" data-toggle="tooltip" data-container="body" data-original-title="分享文章"><a tabindex="0" role="button" data-toggle="popover" data-placement="left" data-html="true" data-trigger="focus" href="javascript:void(0);" data-content="<ul class='share-list'><li><a class="weixin-share"><i class="social-icon-sprite social-icon-weixin"></i><span>分享到微信</span></a></li><li><a href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=1881139527',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','', '推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》( 分享自 @简书 )','https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=weibo','页面编码gb2312|utf-8默认gb2312'));"><i class='social-icon-sprite social-icon-weibo'></i><span>分享到微博</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=qzone')+'&title='+e('推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》'),x=function(){if(!window.open(r,'qzone','toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class='social-icon-sprite social-icon-zone'></i><span>分享到QQ空间</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://twitter.com/share?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=twitter')+'&text='+e('推荐 mac在路上 的文章《tensorflow学习笔记系列(三):tensorflow入门与基本使用》( 分享自 @jianshucom )')+'&related='+e('jianshucom'),x=function(){if(!window.open(r,'twitter','toolbar=0,resizable=1,scrollbars=yes,status=1,width=600,height=600'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class='social-icon-sprite social-icon-twitter'></i><span>分享到Twitter</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://www.facebook.com/dialog/share?app_id=483126645039390&display=popup&href=https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=facebook',x=function(){if(!window.open(r,'facebook','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class='social-icon-sprite social-icon-facebook'></i><span>分享到Facebook</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,r='https://plus.google.com/share?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=google_plus'),x=function(){if(!window.open(r,'google_plus','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})();"><i class='social-icon-sprite social-icon-google'></i><span>分享到Google+</span></a></li><li><a href="javascript:void(function(){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e('https://www.jianshu.com/p/87581c7082ba?utm_campaign=maleskine&utm_content=note&utm_medium=reader_share&utm_source=douban')+'&title='+e('tensorflow学习笔记系列(三):tensorflow入门与基本使用')+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()"><i class='social-icon-sprite social-icon-douban'></i><span>分享到豆瓣</span></a></li></ul>" data-original-title="" title="" class="function-button"><i class="iconfont ic-share"></i></a> <!----></li> <!----></ul></div>
</div>

tensorflow学习入门笔记相关推荐

  1. 深度学习入门笔记系列 ( 二 )——基于 tensorflow 的一些深度学习基础知识

    本系列将分为 8 篇 .今天是第二篇 .主要讲讲 TensorFlow 框架的特点和此系列笔记中涉及到的入门概念 . 1.Tensor .Flow .Session .Graphs TensorFlo ...

  2. 深度学习入门笔记(十五):深度学习框架(TensorFlow和Pytorch之争)

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

  3. tensorflow学习函数笔记

    为什么80%的码农都做不了架构师?>>>    [TensorFlow教程资源](https://my.oschina.net/u/3787228/blog/1794868](htt ...

  4. 深度学习入门笔记系列(三)——感知器模型和 tensorboard 的使用方法

    本系列将分为 8 篇 .今天是第三篇 .主要讲讲感知器模型和 tensorboard 的基本使用方法 . 1. 感知器模型 因为小詹之前写过一篇感知器模型的介绍 ,这里就不赘述了 .有需要巩固的点击如 ...

  5. 深度学习入门笔记(十六):计算机视觉之边缘检测

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

  6. 深度学习入门笔记(五):神经网络的编程基础

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

  7. 深度学习入门笔记(二十):经典神经网络(LeNet-5、AlexNet和VGGNet)

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

  8. 深度学习入门笔记(十八):卷积神经网络(一)

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

  9. 深度学习入门笔记(十七):深度学习的极限在哪?

    欢迎关注WX公众号:[程序员管小亮] 专栏--深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献. 2)本文仅供学术交流,非商用.所以每一部分具 ...

最新文章

  1. spring 通过工厂方法配置Bean
  2. 两台笔记本怎么连接局域网
  3. 对一致性Hash算法,Java代码实现的深入研究
  4. 美团Android资源混淆保护实践
  5. 用命令行批处理bat,设置代理服务器、DNS、网关、WINS等
  6. 加了2个皮肤的art dialog
  7. 如何在Rancher 2.0上快速部署Datadog
  8. Day004 20210209-20210217
  9. 嵌入式linux基础学习全套精品视频教程
  10. MP4转AVI转AMV教程:教你把B站视频导入你的MP3MP4随身听播放器
  11. 【灵感一剖】WPS简历助手使用反馈
  12. html5扁平化设计库,5个大气漂亮的扁平化设计网站赏析|HTML5酷站
  13. uni-app小程序基础知识速览(上)
  14. 男人29岁发奋能成功吗
  15. 南方s730手簿说明书_s730手薄
  16. 一些需要用到的latex语句
  17. MultiTimer | 一款可无限扩展的软件定时器
  18. 我的理想计算机作文300字,我的理想作文300字(精选12篇)
  19. VUE父组件向子组件传递数据
  20. Windows Server 远程桌面连接不上问题解决

热门文章

  1. 拥抱大家庭,nodejs走thrift
  2. 关于web程序中使用KindEditor向数据库插入带有格式的数据时出现的问题
  3. Page类的IsPostBack原理
  4. jquery防止冒泡
  5. Lint found fatal errors while assembling a release target
  6. 解析solidity的event log
  7. shell中变量的取值与赋值
  8. 如何获得阿里技术offer:从《阿里DBA面试题》体味阿里社会招聘
  9. Microsoft Office 2010 Beta测试
  10. vonic 安装的坑