提交 80ed482e 编写于 作者: T Travis CI

Deploy to GitHub Pages: d7b20584

上级 ec82e680
......@@ -434,9 +434,9 @@ lambda_cost
.. autoclass:: paddle.v2.layer.lambda_cost
:noindex:
mse_cost
square_error_cost
--------
.. autoclass:: paddle.v2.layer.mse_cost
.. autoclass:: paddle.v2.layer.square_error_cost
:noindex:
rank_cost
......
......@@ -49,7 +49,7 @@ To recover this relationship between ``X`` and ``Y``, we use a neural network wi
x = data_layer(name='x', size=1)
y = data_layer(name='y', size=1)
y_predict = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
cost = mse_cost(input=y_predict, label=y)
cost = square_error_cost(input=y_predict, label=y)
outputs(cost)
Some of the most fundamental usages of PaddlePaddle are demonstrated:
......
......@@ -3457,14 +3457,14 @@ entire list of get gradient.</li>
</dd></dl>
</div>
<div class="section" id="mse-cost">
<h3>mse_cost<a class="headerlink" href="#mse-cost" title="Permalink to this headline"></a></h3>
<div class="section" id="square-error-cost">
<h3>square_error_cost<a class="headerlink" href="#square-error-cost" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">mse_cost</code></dt>
<dd><p>mean squared error cost:</p>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">square_error_cost</code></dt>
<dd><p>sum of square error cost:</p>
<div class="math">
\[\frac{1}{N}\sum_{i=1}^N(t_i-y_i)^2\]</div>
\[cost = \sum_{i=1}^N(t_i-y_i)^2\]</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
......
......@@ -222,7 +222,7 @@
<span class="n">x</span> <span class="o">=</span> <span class="n">data_layer</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">data_layer</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">y_predict</span> <span class="o">=</span> <span class="n">fc_layer</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">param_attr</span><span class="o">=</span><span class="n">ParamAttr</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">act</span><span class="o">=</span><span class="n">LinearActivation</span><span class="p">(),</span> <span class="n">bias_attr</span><span class="o">=</span><span class="n">ParamAttr</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">))</span>
<span class="n">cost</span> <span class="o">=</span> <span class="n">mse_cost</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">y_predict</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="n">cost</span> <span class="o">=</span> <span class="n">square_error_cost</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">y_predict</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="n">outputs</span><span class="p">(</span><span class="n">cost</span><span class="p">)</span>
</pre></div>
</div>
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -434,9 +434,9 @@ lambda_cost
.. autoclass:: paddle.v2.layer.lambda_cost
:noindex:
mse_cost
square_error_cost
--------
.. autoclass:: paddle.v2.layer.mse_cost
.. autoclass:: paddle.v2.layer.square_error_cost
:noindex:
rank_cost
......
......@@ -55,7 +55,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
# 线性计算网络层: ȳ = wx + b
ȳ = fc_layer(input=x, param_attr=ParamAttr(name='w'), size=1, act=LinearActivation(), bias_attr=ParamAttr(name='b'))
# 计算误差函数,即 ȳ 和真实 y 之间的距离
cost = mse_cost(input= ȳ, label=y)
cost = square_error_cost(input= ȳ, label=y)
outputs(cost)
......@@ -69,7 +69,7 @@ PaddlePaddle是源于百度的一个深度学习平台。这份简短的介绍
- **数据层**:数据层 `data_layer` 是神经网络的入口,它读入数据并将它们传输到接下来的网络层。这里数据层有两个,分别对应于变量 `x` 和 `y`。
- **全连接层**:全连接层 `fc_layer` 是基础的计算单元,这里利用它建模变量之间的线性关系。计算单元是神经网络的核心,PaddlePaddle支持大量的计算单元和任意深度的网络连接,从而可以拟合任意的函数来学习复杂的数据关系。
- **回归误差代价层**:回归误差代价层 `mse_cost` 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。
- **回归误差代价层**:回归误差代价层 `square_error_cost` 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。
定义了网络结构并保存为 `trainer_config.py` 之后,运行以下训练命令:
......
......@@ -81,9 +81,9 @@ PaddlePaddle支持不同类型的输入数据,主要包括四种类型,和
.. code-block:: bash
y_predict = paddle.layer.fc(input=x, size=1, act=paddle.activation.Linear())
cost = paddle.layer.mse_cost(input=y_predict, label=y)
cost = paddle.layer.square_error_cost(input=y_predict, label=y)
其中,x与y为之前描述的输入层;而y_predict是接收x作为输入,接上一个全连接层;cost接收y_predict与y作为输入,接上方误差层。
其中,x与y为之前描述的输入层;而y_predict是接收x作为输入,接上一个全连接层;cost接收y_predict与y作为输入,接上方误差层。
最后一层cost中记录了神经网络的所有拓扑结构,通过组合不同的layer,我们即可完成神经网络的搭建。
......@@ -147,4 +147,4 @@ PaddlePaddle支持不同类型的输入数据,主要包括四种类型,和
.. literalinclude:: src/train.py
:linenos:
有关线性回归的实际应用,可以参考PaddlePaddle book的 `第一章节 <http://book.paddlepaddle.org/index.html>`_。
\ No newline at end of file
有关线性回归的实际应用,可以参考PaddlePaddle book的 `第一章节 <http://book.paddlepaddle.org/index.html>`_。
......@@ -213,7 +213,7 @@ I1116 09:10:17.123440 50 Util.cpp:130] Calling runInitFunctions
I1116 09:10:17.123764 50 Util.cpp:143] Call runInitFunctions done.
[WARNING 2016-11-16 09:10:17,227 default_decorators.py:40] please use keyword arguments in paddle config.
[INFO 2016-11-16 09:10:17,239 networks.py:1282] The input order is [movie_id, title, genres, user_id, gender, age, occupation, rating]
[INFO 2016-11-16 09:10:17,239 networks.py:1289] The output order is [__mse_cost_0__]
[INFO 2016-11-16 09:10:17,239 networks.py:1289] The output order is [__square_error_cost_0__]
I1116 09:10:17.392917 50 Trainer.cpp:170] trainer mode: Normal
I1116 09:10:17.613910 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
I1116 09:10:17.680917 50 PyDataProvider2.cpp:257] loading dataprovider dataprovider::process
......
......@@ -3464,14 +3464,14 @@ entire list of get gradient.</li>
</dd></dl>
</div>
<div class="section" id="mse-cost">
<h3>mse_cost<a class="headerlink" href="#mse-cost" title="永久链接至标题"></a></h3>
<div class="section" id="square-error-cost">
<h3>square_error_cost<a class="headerlink" href="#square-error-cost" title="永久链接至标题"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">mse_cost</code></dt>
<dd><p>mean squared error cost:</p>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">square_error_cost</code></dt>
<dd><p>sum of square error cost:</p>
<div class="math">
\[\frac{1}{N}\sum_{i=1}^N(t_i-y_i)^2\]</div>
\[cost = \sum_{i=1}^N(t_i-y_i)^2\]</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
......
......@@ -230,7 +230,7 @@ y = data_layer(name=&#39;y&#39;, size=1)
# 线性计算网络层: ȳ = wx + b
ȳ = fc_layer(input=x, param_attr=ParamAttr(name=&#39;w&#39;), size=1, act=LinearActivation(), bias_attr=ParamAttr(name=&#39;b&#39;))
# 计算误差函数,即 ȳ 和真实 y 之间的距离
cost = mse_cost(input= ȳ, label=y)
cost = square_error_cost(input= ȳ, label=y)
outputs(cost)
</pre></div>
</div>
......@@ -245,7 +245,7 @@ outputs(cost)
<div><ul class="simple">
<li><strong>数据层</strong>:数据层 <cite>data_layer</cite> 是神经网络的入口,它读入数据并将它们传输到接下来的网络层。这里数据层有两个,分别对应于变量 <cite>x</cite><cite>y</cite></li>
<li><strong>全连接层</strong>:全连接层 <cite>fc_layer</cite> 是基础的计算单元,这里利用它建模变量之间的线性关系。计算单元是神经网络的核心,PaddlePaddle支持大量的计算单元和任意深度的网络连接,从而可以拟合任意的函数来学习复杂的数据关系。</li>
<li><strong>回归误差代价层</strong>:回归误差代价层 <cite>mse_cost</cite> 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。</li>
<li><strong>回归误差代价层</strong>:回归误差代价层 <cite>square_error_cost</cite> 是众多误差代价函数层的一种,它们在训练过程作为网络的出口,用来计算模型的误差,是模型参数优化的目标函数。</li>
</ul>
</div></blockquote>
</li>
......
......@@ -276,10 +276,10 @@ paddle.init<span class="o">(</span><span class="nv">use_gpu</span><span class="o
<p>在定义输入layer之后,我们可以使用其他layer进行组合。在组合时,需要指定layer的输入来源。</p>
<p>例如,我们可以定义如下的layer组合:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nv">y_predict</span> <span class="o">=</span> paddle.layer.fc<span class="o">(</span><span class="nv">input</span><span class="o">=</span>x, <span class="nv">size</span><span class="o">=</span><span class="m">1</span>, <span class="nv">act</span><span class="o">=</span>paddle.activation.Linear<span class="o">())</span>
<span class="nv">cost</span> <span class="o">=</span> paddle.layer.mse_cost<span class="o">(</span><span class="nv">input</span><span class="o">=</span>y_predict, <span class="nv">label</span><span class="o">=</span>y<span class="o">)</span>
<span class="nv">cost</span> <span class="o">=</span> paddle.layer.square_error_cost<span class="o">(</span><span class="nv">input</span><span class="o">=</span>y_predict, <span class="nv">label</span><span class="o">=</span>y<span class="o">)</span>
</pre></div>
</div>
<p>其中,x与y为之前描述的输入层;而y_predict是接收x作为输入,接上一个全连接层;cost接收y_predict与y作为输入,接上方误差层。</p>
<p>其中,x与y为之前描述的输入层;而y_predict是接收x作为输入,接上一个全连接层;cost接收y_predict与y作为输入,接上方误差层。</p>
<p>最后一层cost中记录了神经网络的所有拓扑结构,通过组合不同的layer,我们即可完成神经网络的搭建。</p>
</div>
</div>
......@@ -390,7 +390,7 @@ trainer.train<span class="o">(</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">data</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">paddle</span><span class="o">.</span><span class="n">data_type</span><span class="o">.</span><span class="n">dense_vector</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="n">y_predict</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">fc</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">x</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">act</span><span class="o">=</span><span class="n">paddle</span><span class="o">.</span><span class="n">activation</span><span class="o">.</span><span class="n">Linear</span><span class="p">())</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">data</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">paddle</span><span class="o">.</span><span class="n">data_type</span><span class="o">.</span><span class="n">dense_vector</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="n">cost</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">mse_cost</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">y_predict</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="n">cost</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">square_error_cost</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">y_predict</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">y</span><span class="p">)</span>
<span class="c1"># create parameters</span>
<span class="n">parameters</span> <span class="o">=</span> <span class="n">paddle</span><span class="o">.</span><span class="n">parameters</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">cost</span><span class="p">)</span>
......
......@@ -376,7 +376,7 @@ I1116 <span class="m">09</span>:10:17.123440 <span class="m">50</span> Util.c
I1116 <span class="m">09</span>:10:17.123764 <span class="m">50</span> Util.cpp:143<span class="o">]</span> Call runInitFunctions <span class="k">done</span>.
<span class="o">[</span>WARNING <span class="m">2016</span>-11-16 <span class="m">09</span>:10:17,227 default_decorators.py:40<span class="o">]</span> please use keyword arguments in paddle config.
<span class="o">[</span>INFO <span class="m">2016</span>-11-16 <span class="m">09</span>:10:17,239 networks.py:1282<span class="o">]</span> The input order is <span class="o">[</span>movie_id, title, genres, user_id, gender, age, occupation, rating<span class="o">]</span>
<span class="o">[</span>INFO <span class="m">2016</span>-11-16 <span class="m">09</span>:10:17,239 networks.py:1289<span class="o">]</span> The output order is <span class="o">[</span>__mse_cost_0__<span class="o">]</span>
<span class="o">[</span>INFO <span class="m">2016</span>-11-16 <span class="m">09</span>:10:17,239 networks.py:1289<span class="o">]</span> The output order is <span class="o">[</span>__square_error_cost_0__<span class="o">]</span>
I1116 <span class="m">09</span>:10:17.392917 <span class="m">50</span> Trainer.cpp:170<span class="o">]</span> trainer mode: Normal
I1116 <span class="m">09</span>:10:17.613910 <span class="m">50</span> PyDataProvider2.cpp:257<span class="o">]</span> loading dataprovider dataprovider::process
I1116 <span class="m">09</span>:10:17.680917 <span class="m">50</span> PyDataProvider2.cpp:257<span class="o">]</span> loading dataprovider dataprovider::process
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册