提交 5394b772 编写于 作者: T Travis CI

Deploy to GitHub Pages: f3c42f60

上级 6ac08982
......@@ -307,6 +307,12 @@ sequence_expand
:noindex:
gru_unit
--------
.. autofunction:: paddle.v2.fluid.layers.gru_unit
:noindex:
lstm_unit
---------
.. autofunction:: paddle.v2.fluid.layers.lstm_unit
......
......@@ -2011,6 +2011,56 @@ explain how sequence_expand works:</p>
</div>
</dd></dl>
</div>
<div class="section" id="gru-unit">
<h2>gru_unit<a class="headerlink" href="#gru-unit" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt>
<code class="descclassname">paddle.v2.fluid.layers.</code><code class="descname">gru_unit</code><span class="sig-paren">(</span><em>input</em>, <em>hidden</em>, <em>size</em>, <em>weight=None</em>, <em>bias=None</em>, <em>activation='tanh'</em>, <em>gate_activation='sigmoid'</em><span class="sig-paren">)</span></dt>
<dd><p>GRU unit layer. The equation of a gru step is:</p>
<blockquote>
<div><div class="math">
\[ \begin{align}\begin{aligned}u_t &amp; = actGate(xu_{t} + W_u h_{t-1} + b_u)\\r_t &amp; = actGate(xr_{t} + W_r h_{t-1} + b_r)\\ch_t &amp; = actNode(xc_t + W_c dot(r_t, h_{t-1}) + b_c)\\h_t &amp; = dot((1-u_t), ch_{t-1}) + dot(u_t, h_t)\end{aligned}\end{align} \]</div>
</div></blockquote>
<p>The inputs of gru unit includes <span class="math">\(z_t\)</span>, <span class="math">\(h_{t-1}\)</span>. In terms
of the equation above, the <span class="math">\(z_t\)</span> is split into 3 parts -
<span class="math">\(xu_t\)</span>, <span class="math">\(xr_t\)</span> and <span class="math">\(xc_t\)</span>. This means that in order to
implement a full GRU unit operator for an input, a fully
connected layer has to be applied, such that <span class="math">\(z_t = W_{fc}x_t\)</span>.</p>
<p>This layer has three outputs <span class="math">\(h_t\)</span>, <span class="math">\(dot(r_t, h_{t - 1})\)</span>
and concatenation of <span class="math">\(u_t\)</span>, <span class="math">\(r_t\)</span> and <span class="math">\(ch_t\)</span>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>input</strong> (<em>Variable</em>) &#8211; The fc transformed input value of current step.</li>
<li><strong>hidden</strong> (<em>Variable</em>) &#8211; The hidden value of lstm unit from previous step.</li>
<li><strong>size</strong> (<em>integer</em>) &#8211; The input dimension value.</li>
<li><strong>weight</strong> (<em>ParamAttr</em>) &#8211; The weight parameters for gru unit. Default: None</li>
<li><strong>bias</strong> (<em>ParamAttr</em>) &#8211; The bias parameters for gru unit. Default: None</li>
<li><strong>activation</strong> (<em>string</em>) &#8211; The activation type for cell (actNode). Default: &#8216;tanh&#8217;</li>
<li><strong>gate_activation</strong> (<em>string</em>) &#8211; The activation type for gates (actGate). Default: &#8216;sigmoid&#8217;</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The hidden value, reset-hidden value and gate values.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">tuple</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># assuming we have x_t_data and prev_hidden of size=10</span>
<span class="n">x_t</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</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_t_data</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="n">hidden_val</span><span class="p">,</span> <span class="n">r_h_val</span><span class="p">,</span> <span class="n">gate_val</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">gru_unit</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">x_t</span><span class="p">,</span>
<span class="n">hidden</span> <span class="o">=</span> <span class="n">prev_hidden</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</div>
<div class="section" id="lstm-unit">
<h2>lstm_unit<a class="headerlink" href="#lstm-unit" title="Permalink to this headline"></a></h2>
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -307,6 +307,12 @@ sequence_expand
:noindex:
gru_unit
--------
.. autofunction:: paddle.v2.fluid.layers.gru_unit
:noindex:
lstm_unit
---------
.. autofunction:: paddle.v2.fluid.layers.lstm_unit
......
......@@ -2024,6 +2024,56 @@ explain how sequence_expand works:</p>
</div>
</dd></dl>
</div>
<div class="section" id="gru-unit">
<h2>gru_unit<a class="headerlink" href="#gru-unit" title="永久链接至标题"></a></h2>
<dl class="function">
<dt>
<code class="descclassname">paddle.v2.fluid.layers.</code><code class="descname">gru_unit</code><span class="sig-paren">(</span><em>input</em>, <em>hidden</em>, <em>size</em>, <em>weight=None</em>, <em>bias=None</em>, <em>activation='tanh'</em>, <em>gate_activation='sigmoid'</em><span class="sig-paren">)</span></dt>
<dd><p>GRU unit layer. The equation of a gru step is:</p>
<blockquote>
<div><div class="math">
\[ \begin{align}\begin{aligned}u_t &amp; = actGate(xu_{t} + W_u h_{t-1} + b_u)\\r_t &amp; = actGate(xr_{t} + W_r h_{t-1} + b_r)\\ch_t &amp; = actNode(xc_t + W_c dot(r_t, h_{t-1}) + b_c)\\h_t &amp; = dot((1-u_t), ch_{t-1}) + dot(u_t, h_t)\end{aligned}\end{align} \]</div>
</div></blockquote>
<p>The inputs of gru unit includes <span class="math">\(z_t\)</span>, <span class="math">\(h_{t-1}\)</span>. In terms
of the equation above, the <span class="math">\(z_t\)</span> is split into 3 parts -
<span class="math">\(xu_t\)</span>, <span class="math">\(xr_t\)</span> and <span class="math">\(xc_t\)</span>. This means that in order to
implement a full GRU unit operator for an input, a fully
connected layer has to be applied, such that <span class="math">\(z_t = W_{fc}x_t\)</span>.</p>
<p>This layer has three outputs <span class="math">\(h_t\)</span>, <span class="math">\(dot(r_t, h_{t - 1})\)</span>
and concatenation of <span class="math">\(u_t\)</span>, <span class="math">\(r_t\)</span> and <span class="math">\(ch_t\)</span>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first simple">
<li><strong>input</strong> (<em>Variable</em>) &#8211; The fc transformed input value of current step.</li>
<li><strong>hidden</strong> (<em>Variable</em>) &#8211; The hidden value of lstm unit from previous step.</li>
<li><strong>size</strong> (<em>integer</em>) &#8211; The input dimension value.</li>
<li><strong>weight</strong> (<em>ParamAttr</em>) &#8211; The weight parameters for gru unit. Default: None</li>
<li><strong>bias</strong> (<em>ParamAttr</em>) &#8211; The bias parameters for gru unit. Default: None</li>
<li><strong>activation</strong> (<em>string</em>) &#8211; The activation type for cell (actNode). Default: &#8216;tanh&#8217;</li>
<li><strong>gate_activation</strong> (<em>string</em>) &#8211; The activation type for gates (actGate). Default: &#8216;sigmoid&#8217;</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">返回:</th><td class="field-body"><p class="first">The hidden value, reset-hidden value and gate values.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">返回类型:</th><td class="field-body"><p class="first last">tuple</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># assuming we have x_t_data and prev_hidden of size=10</span>
<span class="n">x_t</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</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_t_data</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="n">hidden_val</span><span class="p">,</span> <span class="n">r_h_val</span><span class="p">,</span> <span class="n">gate_val</span> <span class="o">=</span> <span class="n">fluid</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">gru_unit</span><span class="p">(</span><span class="nb">input</span><span class="o">=</span><span class="n">x_t</span><span class="p">,</span>
<span class="n">hidden</span> <span class="o">=</span> <span class="n">prev_hidden</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</div>
<div class="section" id="lstm-unit">
<h2>lstm_unit<a class="headerlink" href="#lstm-unit" title="永久链接至标题"></a></h2>
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册