Added: incubator/singa/site/trunk/zh/docs/layer.html
URL: 
http://svn.apache.org/viewvc/incubator/singa/site/trunk/zh/docs/layer.html?rev=1833193&view=auto
==============================================================================
--- incubator/singa/site/trunk/zh/docs/layer.html (added)
+++ incubator/singa/site/trunk/zh/docs/layer.html Fri Jun  8 15:29:00 2018
@@ -0,0 +1,799 @@
+
+
+
+<!DOCTYPE html>
+<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
+<head>
+  <meta charset="utf-8">
+  
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  
+  <title>层(Layer) &mdash; incubator-singa 1.1.0 documentation</title>
+  
+
+  
+  
+  
+  
+
+  
+
+  
+  
+    
+
+  
+
+  
+    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
+  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+    <link rel="index" title="Index" href="../genindex.html" />
+    <link rel="search" title="Search" href="../search.html" />
+    <link rel="next" title="前馈网络" href="net.html" />
+    <link rel="prev" title="张量(Tensor)" href="tensor.html" />
+    <link href="../_static/style.css" rel="stylesheet" type="text/css">
+    <!--link href="../_static/fontawesome-all.min.css" rel="stylesheet" 
type="text/css"-->
+       <link rel="stylesheet" 
href="https://use.fontawesome.com/releases/v5.0.13/css/all.css"; 
integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp"
 crossorigin="anonymous">
+    <style>
+       .fa:hover {
+           opacity: 0.7;
+       }
+       .fab:hover {
+           opacity: 0.7;
+       }
+    </style>
+
+
+  
+  <script src="../_static/js/modernizr.min.js"></script>
+
+</head>
+
+<body class="wy-body-for-nav">
+
+   
+  <div class="wy-grid-for-nav">
+
+    
+    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
+      <div class="wy-side-scroll">
+        <div class="wy-side-nav-search">
+          
+
+          
+            <a href="../index.html" class="icon icon-home"> incubator-singa
+          
+
+          
+            
+            <img src="../_static/singa.png" class="logo" alt="Logo"/>
+          
+          </a>
+
+          
+            
+            
+              <div class="version">
+                latest
+              </div>
+            
+          
+
+          
+<div role="search">
+  <form id="rtd-search-form" class="wy-form" action="../search.html" 
method="get">
+    <input type="text" name="q" placeholder="Search docs" />
+    <input type="hidden" name="check_keywords" value="yes" />
+    <input type="hidden" name="area" value="default" />
+  </form>
+</div>
+
+          
+        </div>
+
+        <div class="wy-menu wy-menu-vertical" data-spy="affix" 
role="navigation" aria-label="main navigation">
+          
+            
+            
+              
+            
+            
+              <ul class="current">
+<li class="toctree-l1"><a class="reference internal" 
href="../downloads.html">下载 SINGA</a></li>
+<li class="toctree-l1 current"><a class="reference internal" 
href="index.html">文档</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" 
href="installation.html">安装</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="software_stack.html">软件架构</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="device.html">设备(Device)</a></li>
+<li class="toctree-l2"><a class="reference internal" href="tensor.html">å¼ 
量(Tensor)</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" 
href="#">层(Layer)</a><ul>
+<li class="toctree-l3"><a class="reference internal" href="#python-api">Python 
API</a><ul>
+<li class="toctree-l4"><a class="reference internal" 
href="#singa-layer-engine-cudnn">singa.layer.engine = ‘cudnn’</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-layer-name-conf-none-kwargs">class 
singa.layer.Layer(name, conf=None, **kwargs)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-dummy-name-input-sample-shape-none">class 
singa.layer.Dummy(name, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-conv2d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-data-format-nchw-use-bias-true-w-specs-none-b-specs-none-pad-none-input-sample-shape-none">class
 singa.layer.Conv2D(name, nb_kernels, kernel=3, stride=1, 
border_mode=’same’, cudnn_prefer=’fatest’, data_format=’NCHW’, 
use_bias=True, W_specs=None, b_specs=None, pad=None, 
input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-conv1d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-use-bias-true-w-specs-init-xavier-b-specs-init-constant-value-0-pad-none-input-sample-shape-none">class
 singa.layer.Conv1D(name, nb_kernels, kernel=3, stride=1, 
border_mode=’same’, cudnn_prefer=’fatest’, use_bias=True, 
W_specs={‘init’: ‘Xavier’}, b_specs={‘init’: ‘Constant’, 
‘value’: 0}, pad=None, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-pooling2d-name-mode-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">class
 singa.layer.Pooling2D(name, mode, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-maxpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">class
 singa.layer.MaxPooling2D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-avgpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">class
 singa.layer.AvgPooling2D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-maxpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">class
 singa.layer.MaxPooling1D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-avgpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">class
 singa.layer.AvgPooling1D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-batchnormalization-name-momentum-0-9-beta-specs-none-gamma-specs-none-input-sample-shape-none">class
 singa.layer.BatchNormalization(name, momentum=0.9, beta_specs=None, 
gamma_specs=None, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-lrn-name-size-5-alpha-1-beta-0-75-mode-cross-channel-k-1-input-sample-shape-none">class
 singa.layer.LRN(name, size=5, alpha=1, beta=0.75, mode=’cross_channel’, 
k=1, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-dense-name-num-output-use-bias-true-w-specs-none-b-specs-none-w-transpose-false-input-sample-shape-none">class
 singa.layer.Dense(name, num_output, use_bias=True, W_specs=None, b_specs=None, 
W_transpose=False, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-dropout-name-p-0-5-input-sample-shape-none">class 
singa.layer.Dropout(name, p=0.5, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-activation-name-mode-relu-input-sample-shape-none">class
 singa.layer.Activation(name, mode=’relu’, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-softmax-name-axis-1-input-sample-shape-none">class 
singa.layer.Softmax(name, axis=1, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-flatten-name-axis-1-input-sample-shape-none">class 
singa.layer.Flatten(name, axis=1, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-merge-name-input-sample-shape-none">class 
singa.layer.Merge(name, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-split-name-num-output-input-sample-shape-none">class 
singa.layer.Split(name, num_output, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-concat-name-axis-input-sample-shapes-none">class 
singa.layer.Concat(name, axis, input_sample_shapes=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-slice-name-axis-slice-point-input-sample-shape-none">class
 singa.layer.Slice(name, axis, slice_point, input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-rnn-name-hidden-size-rnn-mode-lstm-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">class
 singa.layer.RNN(name, hidden_size, rnn_mode=’lstm’, dropout=0.0, 
num_stacks=1, input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-lstm-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">class
 singa.layer.LSTM(name, hidden_size, dropout=0.0, num_stacks=1, 
input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#class-singa-layer-gru-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">class
 singa.layer.GRU(name, hidden_size, dropout=0.0, num_stacks=1, 
input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li class="toctree-l2"><a class="reference internal" 
href="net.html">前馈网络</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="initializer.html">初始化器(Initializer)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="loss.html">损失(Loss)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="metric.html">度量(Metric)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="optimizer.html">优化器(Optimizer)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="data.html">数据(Data)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="image_tool.html">图像工具</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="snapshot.html">Snapshot</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="utils.html">Utils</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="model_zoo/index.html">模型库</a></li>
+</ul>
+</li>
+</ul>
+<p class="caption"><span class="caption-text">开发</span></p>
+<ul>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/schedule.html">开发时间表</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/how-contribute.html">如何贡献给 SINGA</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/contribute-code.html">如何贡献代码</a></li>
+</ul>
+<p class="caption"><span class="caption-text">社区</span></p>
+<ul>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/source-repository.html">源代码库</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/mail-lists.html">项目邮件列表</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/issue-tracking.html">问题追踪</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/team-list.html">SINGA团队</a></li>
+</ul>
+
+            
+          
+        </div>
+      </div>
+    </nav>
+
+    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
+
+      
+      <nav class="wy-nav-top" aria-label="top navigation">
+        
+          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
+          <a href="../index.html">incubator-singa</a>
+        
+      </nav>
+
+
+      <div class="wy-nav-content">
+        
+        <div class="rst-content">
+        
+          
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<div role="navigation" aria-label="breadcrumbs navigation">
+
+  <ul class="wy-breadcrumbs">
+    
+      <li><a href="../index.html">Docs</a> &raquo;</li>
+        
+          <li><a href="index.html">文档</a> &raquo;</li>
+        
+      <li>层(Layer)</li>
+    
+    
+      <li class="wy-breadcrumbs-aside">
+        
+            
+        
+      </li>
+    
+  </ul>
+
+  
+  <hr/>
+</div>
+          <div role="main" class="document" itemscope="itemscope" 
itemtype="http://schema.org/Article";>
+           <div itemprop="articleBody">
+            
+  <div class="section" id="layer">
+<span id="layer"></span><h1>层(Layer)<a class="headerlink" href="#layer" 
title="Permalink to this headline">¶</a></h1>
+<div class="section" id="python-api">
+<span id="python-api"></span><h2>Python API<a class="headerlink" 
href="#python-api" title="Permalink to this headline">¶</a></h2>
+<p>Python层将C++层封装成更简单的API。</p>
+<p>示例用法:</p>
+<div class="highlight-python notranslate"><div 
class="highlight"><pre><span></span><span class="kn">from</span> <span 
class="nn">singa</span> <span class="kn">import</span> <span 
class="n">layer</span>
+<span class="kn">from</span> <span class="nn">singa</span> <span 
class="kn">import</span> <span class="n">tensor</span>
+<span class="kn">from</span> <span class="nn">singa</span> <span 
class="kn">import</span> <span class="n">device</span>
+
+<span class="n">layer</span><span class="o">.</span><span 
class="n">engine</span> <span class="o">=</span> <span 
class="s1">&#39;cudnn&#39;</span>  <span class="c1"># to use cudnn layers</span>
+<span class="n">dev</span> <span class="o">=</span> <span 
class="n">device</span><span class="o">.</span><span 
class="n">create_cuda_gpu</span><span class="p">()</span>
+
+<span class="c1"># create a convolution layer</span>
+<span class="n">conv</span> <span class="o">=</span> <span 
class="n">layer</span><span class="o">.</span><span 
class="n">Conv2D</span><span class="p">(</span><span 
class="s1">&#39;conv&#39;</span><span class="p">,</span> <span 
class="mi">32</span><span class="p">,</span> <span class="mi">3</span><span 
class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span 
class="n">pad</span><span class="o">=</span><span class="mi">1</span><span 
class="p">,</span> <span class="n">input_sample_shape</span><span 
class="o">=</span><span class="p">(</span><span class="mi">3</span><span 
class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span 
class="mi">32</span><span class="p">))</span>
+<span class="n">conv</span><span class="o">.</span><span 
class="n">to_device</span><span class="p">(</span><span 
class="n">dev</span><span class="p">)</span>  <span class="c1"># move the layer 
data onto a CudaGPU device</span>
+<span class="n">x</span> <span class="o">=</span> <span 
class="n">tensor</span><span class="o">.</span><span 
class="n">Tensor</span><span class="p">((</span><span class="mi">3</span><span 
class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span 
class="mi">32</span><span class="p">),</span> <span class="n">dev</span><span 
class="p">)</span>
+<span class="n">x</span><span class="o">.</span><span 
class="n">uniform</span><span class="p">(</span><span class="o">-</span><span 
class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span 
class="p">)</span>
+<span class="n">y</span> <span class="o">=</span> <span 
class="n">conv</span><span class="o">.</span><span class="n">foward</span><span 
class="p">(</span><span class="bp">True</span><span class="p">,</span> <span 
class="n">x</span><span class="p">)</span>
+
+<span class="n">dy</span> <span class="o">=</span> <span 
class="n">tensor</span><span class="o">.</span><span 
class="n">Tensor</span><span class="p">()</span>
+<span class="n">dy</span><span class="o">.</span><span 
class="n">reset_like</span><span class="p">(</span><span 
class="n">y</span><span class="p">)</span>
+<span class="n">dy</span><span class="o">.</span><span 
class="n">set_value</span><span class="p">(</span><span 
class="mf">0.1</span><span class="p">)</span>
+<span class="c1"># dp is a list of tensors for parameter gradients</span>
+<span class="n">dx</span><span class="p">,</span> <span class="n">dp</span> 
<span class="o">=</span> <span class="n">conv</span><span 
class="o">.</span><span class="n">backward</span><span class="p">(</span><span 
class="n">kTrain</span><span class="p">,</span> <span class="n">dy</span><span 
class="p">)</span>
+</pre></div>
+</div>
+<hr class="docutils" />
+<div class="section" id="singa-layer-engine-cudnn">
+<span id="singa-layer-engine-cudnn"></span><h3>singa.layer.engine = 
‘cudnn’<a class="headerlink" href="#singa-layer-engine-cudnn" 
title="Permalink to this headline">¶</a></h3>
+<p>引擎(engine)是层标识符的前缀。
+这个值可能是[cudnn’,’singacpp’,’singacuda’,’singacl’]之一,分别用cudnn库,Cpp,Cuda和OpenCL实现。
 例如,CudnnConvolution层由’cudnn_convolution’标识; 
‘singacpp_convolution’用于卷积层; 
有些层的实现只使用tensor函数,因
此它们对底层设备是透明的。 对于这些层,它们将å…
·æœ‰å¤šä¸ªæ 
‡è¯†ç¬¦ï¼Œä¾‹å¦‚,singacpp_dropout,singacuda_dropout和singacl_dropoutå…
¨éƒ½ç”¨äºŽDropout层。 此外,它还有一个额外的æ 
‡è¯†ç¬¦â€™singa’,即’singa_dropout’也代表Dropout层。</p>
+<p>引擎是大小写敏感的。每个python层将会用引擎属性创建正确的层。</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-layer-layer-name-conf-none-kwargs">
+<span id="class-singa-layer-layer-name-conf-none-kwargs"></span><h3>class 
singa.layer.Layer(name, conf=None, **kwargs)<a class="headerlink" 
href="#class-singa-layer-layer-name-conf-none-kwargs" title="Permalink to this 
headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">object</span></code></p>
+<p>Python层的基类。
+典型地,层实例的生命周期包括:</p>
+<ol class="simple">
+<li>构造
层没有input_sample_shapes,转到2;用input_sample_shapes构建层,转到3</li>
+<li>调用setup来创建参数并设置其他元字段</li>
+<li>调用前向传播或访问层成员</li>
+<li>调用后向传播并获取参数完成更新</li>
+</ol>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>name (str)</strong> – 层名</li>
+</ul>
+<hr class="docutils" />
+<div class="section" id="setup-in-shapes">
+<span id="setup-in-shapes"></span><h4>setup(in_shapes)<a class="headerlink" 
href="#setup-in-shapes" title="Permalink to this headline">¶</a></h4>
+<p>调用C++setup函数创建参数并设置元数据。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>in_shapes</strong> – 如果层接受单个输å…
¥tensor,则in_shapes是指定输入tensor形状的单个元组; 
如果该层接受多个输å…
¥tensor(例如,concatenation层),则in_shapes是元组的å…
ƒç»„,每个元组对于一个输入tensor</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" id="caffe-layer">
+<span id="caffe-layer"></span><h4>caffe_layer()<a class="headerlink" 
href="#caffe-layer" title="Permalink to this headline">¶</a></h4>
+<p>基于caffe层的配置创建一个SINGA层</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="get-output-sample-shape">
+<span id="get-output-sample-shape"></span><h4>get_output_sample_shape()<a 
class="headerlink" href="#get-output-sample-shape" title="Permalink to this 
headline">¶</a></h4>
+<p>在setup以获得输出样本的形状后被调用</p>
+<p><strong>返回值:</strong> 单个输出tensor的元组;如果该层å…
·æœ‰å¤šä¸ªè¾“出,则为元组列表</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="param-names">
+<span id="param-names"></span><h4>param_names()<a class="headerlink" 
href="#param-names" title="Permalink to this headline">¶</a></h4>
+<p><strong>返回值:</strong> 
字符串列表,每个值代表一个参数tensor的名称</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="param-values">
+<span id="param-values"></span><h4>param_values()<a class="headerlink" 
href="#param-values" title="Permalink to this headline">¶</a></h4>
+<p>返回参数值tensor。
+参数tesnor不作为层成员存储。由于层设备的更改,cpp 
tensor可能会移动到diff设备上,这会导致不一致。</p>
+<p><strong>返回值:</strong> 
tensor列表,每个参数对应列表中的一个</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="forward-flag-x">
+<span id="forward-flag-x"></span><h4>forward(flag, x)<a class="headerlink" 
href="#forward-flag-x" title="Permalink to this headline">¶</a></h4>
+<p>当前层的前向传播。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – True (kTrain) for training (kEval); False for 
evaluating; other values for furture use.</li>
+<li><strong>x (Tensor or list<Tensor>)</strong> – an input tensor if the 
layer is connected from a single layer; a list of tensors if the layer is 
connected from multiple layers.</li>
+</ul>
+<p><strong>返回值:</strong> 
如果该层被连接在一个单独的层则返回tensor;如果被连接到多个层,则返回一个tensor列表</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="backward-flag-dy">
+<span id="backward-flag-dy"></span><h4>backward(flag, dy)<a class="headerlink" 
href="#backward-flag-dy" title="Permalink to this headline">¶</a></h4>
+<p>当前层的后向传播。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag (int)</strong> – 保留为以后使用</li>
+<li><strong>dy (Tensor or list<Tensor>)</strong> – 与目æ 
‡æŸå¤±ç›¸å¯¹åº”的梯度tensor</li>
+</ul>
+<p><strong>返回值:</strong> &lt;dx, &lt;dp1, dp2..&gt;&gt;,dx是输å…
¥x的梯度,dpi是第i个参数的梯度</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="to-device-device">
+<span id="to-device-device"></span><h4>to_device(device)<a class="headerlink" 
href="#to-device-device" title="Permalink to this headline">¶</a></h4>
+<p>将层状态tensor移至指定设备。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>device</strong> – 
swig转换的设备,由singa.device创建</li>
+</ul>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-layer-dummy-name-input-sample-shape-none">
+<span 
id="class-singa-layer-dummy-name-input-sample-shape-none"></span><h3>class 
singa.layer.Dummy(name, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-dummy-name-input-sample-shape-none" title="Permalink 
to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>一个虚拟层,仅用于向前/向后传递数据(输å…
¥/输出是单个tensor)。</p>
+<div class="section" id="forward-flag-x">
+<span id="id1"></span><h4>forward(flag, x)<a class="headerlink" 
href="#forward-flag-x" title="Permalink to this headline">¶</a></h4>
+<p><strong>返回值:</strong> 输入x</p>
+</div>
+<div class="section" id="backward-falg-dy">
+<span id="backward-falg-dy"></span><h4>backward(falg, dy)<a class="headerlink" 
href="#backward-falg-dy" title="Permalink to this headline">¶</a></h4>
+<p><strong>返回值:</strong> dy,[]</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-conv2d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-data-format-nchw-use-bias-true-w-specs-none-b-specs-none-pad-none-input-sample-shape-none">
+<span 
id="class-singa-layer-conv2d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-data-format-nchw-use-bias-true-w-specs-none-b-specs-none-pad-none-input-sample-shape-none"></span><h3>class
 singa.layer.Conv2D(name, nb_kernels, kernel=3, stride=1, 
border_mode=’same’, cudnn_prefer=’fatest’, data_format=’NCHW’, 
use_bias=True, W_specs=None, b_specs=None, pad=None, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-conv2d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-data-format-nchw-use-bias-true-w-specs-none-b-specs-none-pad-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>创建一个层做2D卷积。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>nb_kernels (int)</strong> – 输入tensor的通道(æ 
¸ï¼‰æ•°</li>
+<li><strong>kernel</strong> – 一个或一对整型数表示æ 
¸çš„高和宽</li>
+<li><strong>stride</strong> – 
一个或一对整型数表示步长的高和宽</li>
+<li><strong>border_mode (string)</strong> – 填充
模式,不区分大小写,‘valid’ -&gt; 在高和宽长度上补0 
‘same’ -&gt; 填充核一半(下取整)数目的0,核必
须是奇数</li>
+<li><strong>cudnn_prefer (string)</strong> – 
偏好的cudnn卷积算法,可以是‘fatest’, ‘autotune’, 
‘limited_workspace’和‘no_workspace’</li>
+<li><strong>data_format (string)</strong> – ‘NCHW’或‘NHWC’</li>
+<li><strong>use_bias (bool)</strong> – True或False</li>
+<li><strong>pad</strong> – 一个或一对整型数表示填充
的高和宽</li>
+<li><strong>W_specs (dict)</strong> – 用于指定权重矩阵的规æ 
¼ï¼Œå­—段包括代表参数名称的‘name’,代表学习
速率乘数的’lr_mult,代表权重衰减乘数的’‘decay_mult’,代表初始化方法的’init’,å
…¶å¯ä»¥æ˜¯â€™gaussian’,’uniform’,’ 
xavier’,相应的初始化方法为’‘’std’,’mean’,’high’,’low’。TODO(wangwei)’clamp’为渐变约束,value为æ
 ‡é‡ï¼Œâ€™regularizer’为正规化,目前支持’l2’</li>
+<li><strong>b_specs (dict)</strong> – 偏移向量的超
参数,同W_specs类似</li>
+<li><strong>name (string)</strong> – 层名</li>
+<li><strong>input_sample_shape</strong> – 用于输入tensor形状的三å…
ƒç»„,例如(通道,高度,宽度)或(高度,宽度,通道)</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-conv1d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-use-bias-true-w-specs-init-xavier-b-specs-init-constant-value-0-pad-none-input-sample-shape-none">
+<span 
id="class-singa-layer-conv1d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-use-bias-true-w-specs-init-xavier-b-specs-init-constant-value-0-pad-none-input-sample-shape-none"></span><h3>class
 singa.layer.Conv1D(name, nb_kernels, kernel=3, stride=1, 
border_mode=’same’, cudnn_prefer=’fatest’, use_bias=True, 
W_specs={‘init’: ‘Xavier’}, b_specs={‘init’: ‘Constant’, 
‘value’: 0}, pad=None, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-conv1d-name-nb-kernels-kernel-3-stride-1-border-mode-same-cudnn-prefer-fatest-use-bias-true-w-specs-init-xavier-b-specs-init-constant-value-0-pad-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Conv2D</span></code></p>
+<p>构建1D卷积层。
+大部分参数与Conv2D的参数相同,除了核,步长,填充
值,这是一个标量而不是元组。 input_sample_shape是一个å…
·æœ‰å•个输入特征长度值的元组。</p>
+<div class="section" id="get-output-sample-shape">
+<span id="id2"></span><h4>get_output_sample_shape()<a class="headerlink" 
href="#get-output-sample-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-pooling2d-name-mode-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">
+<span 
id="class-singa-layer-pooling2d-name-mode-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"></span><h3>class
 singa.layer.Pooling2D(name, mode, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-pooling2d-name-mode-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>2D池化层进行最大或平均池化。
+所有的参数都与Conv2D相同,除了下面的参数。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>mode</strong> – 池
化模式,model_pb2.PoolingConf.MAX或model_pb2.PoolingConf.AVE</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-maxpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">
+<span 
id="class-singa-layer-maxpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"></span><h3>class
 singa.layer.MaxPooling2D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-maxpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类: <code class="docutils literal notranslate"><span 
class="pre">singa.layer.Pooling2D</span></code></p>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-avgpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">
+<span 
id="class-singa-layer-avgpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"></span><h3>class
 singa.layer.AvgPooling2D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-avgpooling2d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类: <code class="docutils literal notranslate"><span 
class="pre">singa.layer.Pooling2D</span></code></p>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-maxpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">
+<span 
id="class-singa-layer-maxpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"></span><h3>class
 singa.layer.MaxPooling1D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-maxpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类: <code class="docutils literal notranslate"><span 
class="pre">singa.layer.MaxPooling2D</span></code></p>
+<p>get_output_sample_shape()</p>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-avgpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none">
+<span 
id="class-singa-layer-avgpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"></span><h3>class
 singa.layer.AvgPooling1D(name, kernel=3, stride=2, border_mode=’same’, 
pad=None, data_format=’NCHW’, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-avgpooling1d-name-kernel-3-stride-2-border-mode-same-pad-none-data-format-nchw-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类: <code class="docutils literal notranslate"><span 
class="pre">singa.layer.AvgPooling2D</span></code></p>
+<p>get_output_sample_shape()</p>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-batchnormalization-name-momentum-0-9-beta-specs-none-gamma-specs-none-input-sample-shape-none">
+<span 
id="class-singa-layer-batchnormalization-name-momentum-0-9-beta-specs-none-gamma-specs-none-input-sample-shape-none"></span><h3>class
 singa.layer.BatchNormalization(name, momentum=0.9, beta_specs=None, 
gamma_specs=None, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-batchnormalization-name-momentum-0-9-beta-specs-none-gamma-specs-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>批量正则化。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>momentum (float)</strong> – 用于运行的均值和方差</li>
+<li><strong>beta_specs (dict)</strong> – 字典,包
括beta参数的字段:’name’参数名称’;lr_mult’学习
速率乘数;’decay_mult’权重衰减乘数;’init’初始化方法;可以是’gaussian’,’uniform’和’xavier’,’std’,’mean’,’high’,’low’表示相应初始化方法;’clamp’表示梯度约束,值是æ
 ‡é‡ï¼›â€™regularizer’用于正则化,目前支持’l2’</li>
+<li><strong>gamma_specs (dict)</strong> – 同beta_specs类似, 
但用于gamma参数.</li>
+<li><strong>name (string)</strong> – 层名</li>
+<li><strong>input_sample_shape (tuple)</strong> – 
整型数,至少一个</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-lrn-name-size-5-alpha-1-beta-0-75-mode-cross-channel-k-1-input-sample-shape-none">
+<span 
id="class-singa-layer-lrn-name-size-5-alpha-1-beta-0-75-mode-cross-channel-k-1-input-sample-shape-none"></span><h3>class
 singa.layer.LRN(name, size=5, alpha=1, beta=0.75, mode=’cross_channel’, 
k=1, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-lrn-name-size-5-alpha-1-beta-0-75-mode-cross-channel-k-1-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>局部响应归一化。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>size (int)</strong> – 用于归一化的通道数.</li>
+<li><strong>mode (string)</strong> – ‘cross_channel’</li>
+<li><strong>input_sample_shape (tuple)</strong> – 3维元组,(channel, 
height, width)</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-dense-name-num-output-use-bias-true-w-specs-none-b-specs-none-w-transpose-false-input-sample-shape-none">
+<span 
id="class-singa-layer-dense-name-num-output-use-bias-true-w-specs-none-b-specs-none-w-transpose-false-input-sample-shape-none"></span><h3>class
 singa.layer.Dense(name, num_output, use_bias=True, W_specs=None, b_specs=None, 
W_transpose=False, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-dense-name-num-output-use-bias-true-w-specs-none-b-specs-none-w-transpose-false-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>进行线性或放射变换,也被叫做内积或全连接层。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>num_output (int)</strong> – 输出特征长度</li>
+<li><strong>use_bias (bool)</strong> – 转换后的特征向量是否加
上偏移向量</li>
+<li><strong>W_specs (dict)</strong> – 包
含权值矩阵的字段:’name’参数名称’;lr_mult’学习
速率乘数;’decay_mult’权重衰减乘数;’init’初始化方法;可以是’gaussian’,’uniform’和’xavier’,’std’,’mean’,’high’,’low’表示相应初始化方法;’clamp’表示梯度约束,值是æ
 ‡é‡ï¼›â€™regularizer’用于正则化,目前支持’l2’</li>
+<li><strong>b_specs (dict)</strong> – 偏移向量的字段, 
同W_specs类似</li>
+<li><strong>W_transpose (bool)</strong> – 
如果为真,输出为x*W.T+b</li>
+<li><strong>input_sample_shape (tuple)</strong> – 输入特征长度</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-dropout-name-p-0-5-input-sample-shape-none">
+<span 
id="class-singa-layer-dropout-name-p-0-5-input-sample-shape-none"></span><h3>class
 singa.layer.Dropout(name, p=0.5, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-dropout-name-p-0-5-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>Dropout层</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>p (float)</strong> – 随机丢掉一个元素(即将å…
¶ä¸­è®¾ä¸º0)的概率</li>
+<li><strong>name (string)</strong> – 层名</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-activation-name-mode-relu-input-sample-shape-none">
+<span 
id="class-singa-layer-activation-name-mode-relu-input-sample-shape-none"></span><h3>class
 singa.layer.Activation(name, mode=’relu’, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-activation-name-mode-relu-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>激励层</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>name (string)</strong> – 层名</li>
+<li><strong>mode (string)</strong> – ‘relu’, ‘sigmoid’或 
‘tanh’</li>
+<li><strong>input_sample_shape (tuple)</strong> – 单个样本的形状</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-softmax-name-axis-1-input-sample-shape-none">
+<span 
id="class-singa-layer-softmax-name-axis-1-input-sample-shape-none"></span><h3>class
 singa.layer.Softmax(name, axis=1, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-softmax-name-axis-1-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>采用SoftMax。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>axis (int)</strong> – 对[axis, 
-1)的数据逐个进行SoftMax</li>
+<li><strong>input_sample_shape (tuple)</strong> – 单个样本的形状</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-flatten-name-axis-1-input-sample-shape-none">
+<span 
id="class-singa-layer-flatten-name-axis-1-input-sample-shape-none"></span><h3>class
 singa.layer.Flatten(name, axis=1, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-flatten-name-axis-1-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>将输入tensor重塑为一个矩阵。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>axis (int)</strong> – 根据指定维度将输å…
¥é‡å¡‘为矩阵,[0,axis)作为行,[axis, -1)作为列</li>
+<li><strong>input_sample_shape (tuple)</strong> – 单个样本的形状</li>
+</ul>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-layer-merge-name-input-sample-shape-none">
+<span 
id="class-singa-layer-merge-name-input-sample-shape-none"></span><h3>class 
singa.layer.Merge(name, input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-merge-name-input-sample-shape-none" title="Permalink 
to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>对所有输入tensor求和。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>input_sample_shape</strong> – 输入样本的形状。所有æ 
·æœ¬çš„形状应该一致。</li>
+</ul>
+<div class="section" id="setup-in-shape">
+<span id="setup-in-shape"></span><h4>setup(in_shape)<a class="headerlink" 
href="#setup-in-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+<div class="section" id="get-output-sample-shape">
+<span id="id3"></span><h4>get_output_sample_shape()<a class="headerlink" 
href="#get-output-sample-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+<div class="section" id="forward-flag-inputs">
+<span id="forward-flag-inputs"></span><h4>forward(flag, inputs)<a 
class="headerlink" href="#forward-flag-inputs" title="Permalink to this 
headline">¶</a></h4>
+<p>通过求和合并所有输入tensor。
+TODO(wangwei) 元素级别的合并操作。</p>
+<p><strong>返回值:</strong> 单个tensor,包含所有输å…
¥tensor的和</p>
+</div>
+<div class="section" id="backward-flag-grad">
+<span id="backward-flag-grad"></span><h4>backward(flag, grad)<a 
class="headerlink" href="#backward-flag-grad" title="Permalink to this 
headline">¶</a></h4>
+<p>复制每个输入层的梯度tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>grad</strong> - 梯度tensor</li>
+</ul>
+<p><strong>返回值:</strong> tensor列表,每个输入层对应å…
¶ä¸­ä¸€ä¸ª</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-split-name-num-output-input-sample-shape-none">
+<span 
id="class-singa-layer-split-name-num-output-input-sample-shape-none"></span><h3>class
 singa.layer.Split(name, num_output, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-split-name-num-output-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>生成输入tensor的多个副本。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>num_output (int)</strong> – 待生成的输出tensor数目</li>
+<li><strong>input_sample_shape()</strong> – 包
含一个整型数,代表输入样本特征大小</li>
+</ul>
+<div class="section" id="setup-in-shape">
+<span id="id4"></span><h4>setup(in_shape)<a class="headerlink" 
href="#setup-in-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+<div class="section" id="get-output-sample-shape">
+<span id="id5"></span><h4>get_output_sample_shape()<a class="headerlink" 
href="#get-output-sample-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+<div class="section" id="forward">
+<span id="forward"></span><h4>forward()<a class="headerlink" href="#forward" 
title="Permalink to this headline">¶</a></h4>
+<p>生成输入tensor的多个副本。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 没有用到</li>
+<li><strong>input</strong> – 单个输入tensor</li>
+</ul>
+<p><strong>返回值:</strong> 输出tensor列表,每个对应输å…
¥çš„一个拷贝</p>
+</div>
+<div class="section" id="backward">
+<span id="backward"></span><h4>backward()<a class="headerlink" 
href="#backward" title="Permalink to this headline">¶</a></h4>
+<p>对所有输入tensor求和得到单个输出tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>grad</strong> - 梯度tensor</li>
+</ul>
+<p><strong>返回值:</strong> 一个tensor,代表所有输å…
¥æ¢¯åº¦tensor的求和</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-concat-name-axis-input-sample-shapes-none">
+<span 
id="class-singa-layer-concat-name-axis-input-sample-shapes-none"></span><h3>class
 singa.layer.Concat(name, axis, input_sample_shapes=None)<a class="headerlink" 
href="#class-singa-layer-concat-name-axis-input-sample-shapes-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>将tensor竖直(axis=0)或水平(axis=1)拼接。目前仅
支持2维tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>axis (int)</strong> – 0表示拼接行; 1表示拼接列;</li>
+<li><strong>input_sample_shapes</strong> – 样本形状的å…
ƒç»„列表,每个对应一个输入样本的tensor</li>
+</ul>
+<div class="section" id="forward-flag-inputs">
+<span id="id6"></span><h4>forward(flag, inputs)<a class="headerlink" 
href="#forward-flag-inputs" title="Permalink to this headline">¶</a></h4>
+<p>拼接所有输入tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 同Layer::forward()</li>
+<li><strong>input</strong> – tensor列表</li>
+</ul>
+<p><strong>返回值:</strong> 一个拼接后的tensor</p>
+</div>
+<div class="section" id="backward-flag-dy">
+<span id="id7"></span><h4>backward(flag, dy)<a class="headerlink" 
href="#backward-flag-dy" title="Permalink to this headline">¶</a></h4>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – same as Layer::backward()</li>
+<li><strong>dy (Tensor)</strong> – the gradient tensors of y w.r.t objective 
loss</li>
+</ul>
+<p><strong>返回值:</strong> 元组(dx, []), 
dx是tensor列表,对应输入的梯度;[]是空列表</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-slice-name-axis-slice-point-input-sample-shape-none">
+<span 
id="class-singa-layer-slice-name-axis-slice-point-input-sample-shape-none"></span><h3>class
 singa.layer.Slice(name, axis, slice_point, input_sample_shape=None)<a 
class="headerlink" 
href="#class-singa-layer-slice-name-axis-slice-point-input-sample-shape-none" 
title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>将输å…
¥tensor沿竖直(axis=0)或水平(axis=1)分成多个子tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>axis (int)</strong> – 0代表分割行; 1代表分割列;</li>
+<li><strong>slice_point (list)</strong> – 
沿着轴分割的位置;n-1个分割点对应n个子tensor;</li>
+<li><strong>input_sample_shape</strong> – 输入样本tensor的形状</li>
+</ul>
+<div class="section" id="get-output-sample-shape">
+<span id="id8"></span><h4>get_output_sample_shape()<a class="headerlink" 
href="#get-output-sample-shape" title="Permalink to this headline">¶</a></h4>
+</div>
+<div class="section" id="forward-flag-x">
+<span id="id9"></span><h4>forward(flag, x)<a class="headerlink" 
href="#forward-flag-x" title="Permalink to this headline">¶</a></h4>
+<p>沿给定轴分割输入tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 同Layer::forward()</li>
+<li><strong>x</strong> – 单个输入tensor</li>
+</ul>
+<p><strong>返回值:</strong> 输出tensor列表</p>
+</div>
+<div class="section" id="backward-flag-grads">
+<span id="backward-flag-grads"></span><h4>backward(flag, grads)<a 
class="headerlink" href="#backward-flag-grads" title="Permalink to this 
headline">¶</a></h4>
+<p>拼接所有梯度tensor以生成一个输出tensor。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 同Layer::backward()</li>
+<li><strong>grads</strong> – 
tensor列表,每个对应一个分割的梯度tensor
+<strong>返回值:</strong> 元组(dx, []), 
dx是一个tensor,对应原始输入的梯度;[]是空列表</li>
+</ul>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-rnn-name-hidden-size-rnn-mode-lstm-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">
+<span 
id="class-singa-layer-rnn-name-hidden-size-rnn-mode-lstm-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"></span><h3>class
 singa.layer.RNN(name, hidden_size, rnn_mode=’lstm’, dropout=0.0, 
num_stacks=1, input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-rnn-name-hidden-size-rnn-mode-lstm-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.Layer</span></code></p>
+<p>递归层包含4个单元,即lstm, gru, tanh和relu。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>hidden_size</strong> – 隐含层特征大小,同所有层的å 
†æ ˆã€‚</li>
+<li><strong>rnn_mode</strong> – 决定了RNN单元,可以是‘lstm’, 
‘gru’, ‘tanh’和 
‘relu’。对于每种模式,可以参考cudnn手册。</li>
+<li><strong>num_stacks</strong> – rnn层的堆æ 
ˆæ•°é‡ã€‚这不同于需要展开的序列长度。</li>
+<li><strong>input_mode</strong> – ‘linear’,通过线性变换将输å…
¥ç‰¹å¾x转换成大小为hidden_size的特征向量;’skip’,仅
要求输入特征大小等于hidden_size。</li>
+<li><strong>bidirection</strong> – 对于双向RNN为真。</li>
+<li><strong>param_specs</strong> – RNN参数的初始化配置。</li>
+<li><strong>input_sample_shape</strong> – 包含一个整型数,代表输å…
¥æ ·æœ¬çš„特征大小。</li>
+</ul>
+<div class="section" id="forward-flag-inputs">
+<span id="id10"></span><h4>forward(flag, inputs)<a class="headerlink" 
href="#forward-flag-inputs" title="Permalink to this headline">¶</a></h4>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – True(kTrain) 
代表训练;False(kEval)代表验证; 其他值用作以后使用。</li>
+<li><strong>&lt;x1, x2,..xn, hx, cx&gt;</strong> – 其中,xi是输å…
¥(inputs,)第i个位置的tensor,它的形状是 (batch_size, 
input_feature_length); xi的batch_size必须大于xi + 1的大小; 
hx是初始隐藏状态,形状是(num_stacks * 
bidirection?2:1,batch_size,hidden_size)。 
cx是与hy相同形状的初始细胞状态张量。 cx仅对lstm有效。 
对于其他RNN,不存在cx。 
hx和cx都可以是没有形状和数据的虚拟张量。
+返回值:&lt;y1,y2,… yn,hy,cy&gt;,å…
¶ä¸­yi是第i个位置的输出张量,其形状是(batch_size,hidden_size 
*双向?2:1)。 hy是最终的隐藏状态张量。 
cx是最终的细胞状态张量。 cx仅用于lstm。</li>
+</ul>
+</div>
+<div class="section" id="backward-flag-grad">
+<span id="id11"></span><h4>backward(flag, grad)<a class="headerlink" 
href="#backward-flag-grad" title="Permalink to this headline">¶</a></h4>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 未来使用</li>
+<li><strong>&lt;dy1, dy2,..dyn, dhy, dcy&gt;</strong> - 其中,dyi是(grad,) 
第i个位置的梯度,它的形状是 (batch_size, hidden_size*bidirection?2 
(i-th) – 1); dhy是最终隐藏状态的渐变,它的形状是(num_stacks 
*双向?2:1,batch_size,hidden_size)。dcy是最终单å…
ƒçŠ¶æ€çš„æ¢¯åº¦ã€‚ cx仅对lstm有效,其他RNN不存在cx。 
dhy和dcy都可以是没有形状和数据的虚拟tensor。</li>
+</ul>
+<p><strong>返回值:</strong> &lt;dx1,dx2,… dxn,dhx,dcx&gt;,å…
¶ä¸­dxi是第i个输入的梯度张
量,它的形状是(batch_size,input_feature_length)。 
dhx是初始隐藏状态的梯度。 dcx是初始单元状态的梯度,仅
对lstm有效。</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-lstm-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">
+<span 
id="class-singa-layer-lstm-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"></span><h3>class
 singa.layer.LSTM(name, hidden_size, dropout=0.0, num_stacks=1, 
input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-lstm-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.RNN</span></code></p>
+</div>
+<hr class="docutils" />
+<div class="section" 
id="class-singa-layer-gru-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none">
+<span 
id="class-singa-layer-gru-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"></span><h3>class
 singa.layer.GRU(name, hidden_size, dropout=0.0, num_stacks=1, 
input_mode=’linear’, bidirectional=False, param_specs=None, 
input_sample_shape=None)<a class="headerlink" 
href="#class-singa-layer-gru-name-hidden-size-dropout-0-0-num-stacks-1-input-mode-linear-bidirectional-false-param-specs-none-input-sample-shape-none"
 title="Permalink to this headline">¶</a></h3>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.layer.RNN</span></code></p>
+<hr class="docutils" />
+<div class="section" id="singa-layer-get-layer-list">
+<span 
id="singa-layer-get-layer-list"></span><h4>singa.layer.get_layer_list()<a 
class="headerlink" href="#singa-layer-get-layer-list" title="Permalink to this 
headline">¶</a></h4>
+<p>返回包含所有支持图层的标识符(标签)的字符串列表</p>
+<hr class="docutils" />
+</div>
+</div>
+</div>
+</div>
+
+
+           </div>
+           
+          </div>
+          <footer>
+  
+    <div class="rst-footer-buttons" role="navigation" aria-label="footer 
navigation">
+      
+        <a href="net.html" class="btn btn-neutral float-right" 
title="前馈网络" accesskey="n" rel="next">Next <span class="fa 
fa-arrow-circle-right"></span></a>
+      
+      
+        <a href="tensor.html" class="btn btn-neutral" title="张量(Tensor)" 
accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 
Previous</a>
+      
+    </div>
+  
+
+  <hr/>
+
+  <div role="contentinfo">
+    <p>
+        &copy; Copyright 2018 The Apache Software Foundation. All rights 
reserved. Apache SINGA, Apache, the Apache feather logo, and the Apache SINGA 
project logos are trademarks of The Apache Software Foundation. All other marks 
mentioned may be trademarks or registered trademarks of their respective 
owners..
+
+    </p>
+  </div>
+  Built with <a href="http://sphinx-doc.org/";>Sphinx</a> using a <a 
href="https://github.com/rtfd/sphinx_rtd_theme";>theme</a> provided by <a 
href="https://readthedocs.org";>Read the Docs</a>. 
+
+</footer>
+
+        </div>
+      </div>
+
+    </section>
+
+  </div>
+  
+
+
+  
+
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'1.1.0',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+
+  
+
+  
+  
+    <script type="text/javascript" src="../_static/js/theme.js"></script>
+  
+
+  <script type="text/javascript">
+      jQuery(function () {
+          SphinxRtdTheme.Navigation.enable(true);
+      });
+  </script>
+
+<div class="rst-versions" data-toggle="rst-versions" role="note" 
aria-label="versions">
+  <span class="rst-current-version" data-toggle="rst-current-version">
+    <span class="fa fa-book"> incubator-singa </span>
+    v: latest
+    <span class="fa fa-caret-down"></span>
+  </span>
+  <div class="rst-other-versions">
+      <dl>
+          <dt>Languages</dt>
+          <dd><a href="../../en/index.html">English</a></dd>
+          <dd><a href="../../zh/index.html">中文</a></dd>
+      </dl>
+      <dl>
+          <dt>Versions</dt>
+          <dd><a href="http://singa.apache.org/v0.3.0/";>0.3</a></dd>
+          <dd><a href="http://singa.apache.org/v1.1.0/";>1.1</a></dd>
+      </dl>
+
+  </div>
+  <a href="http://incubator.apache.org/";> <img src= "../_static/apache.png" 
style="background-color:white;"> </a>
+
+  <a href="https://github.com/apache/incubator-singa"; class="fa fa-github" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a 
href="https://aws.amazon.com/marketplace/seller-profile?id=5bcac385-12c4-4802-aec7-351e09b77b4c";
 class="fab fa-aws" style="padding: 10px; font-size: 20px; width: 30px; 
text-align: center; text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://hub.docker.com/r/nusdbsystem/singa/"; class="fab fa-docker" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a> 
+  <a href="https://www.linkedin.com/groups/13550034"; class="fa fa-linkedin" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://twitter.com/ApacheSinga"; class="fa fa-twitter" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://www.facebook.com/Apache-SINGA-347284219056544/"; class="fa 
fa-facebook" style="padding: 10px; font-size: 20px; width: 30px; text-align: 
center; text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://www.researchgate.net/project/Apache-SINGA"; class="fab 
fa-researchgate" style="padding: 10px; font-size: 20px; width: 30px; 
text-align: center; text-decoration: none; margin: 5px 2px;"></a>
+
+</div>
+
+ <a href="https://github.com/apache/incubator-singa";>
+    <img style="position: absolute; top: 0; right: 0; border: 0; z-index: 
10000;"
+        
src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png";
+        alt="Fork me on GitHub">
+</a>
+
+ 
+
+
+</body>
+</html>
\ No newline at end of file

Added: incubator/singa/site/trunk/zh/docs/loss.html
URL: 
http://svn.apache.org/viewvc/incubator/singa/site/trunk/zh/docs/loss.html?rev=1833193&view=auto
==============================================================================
--- incubator/singa/site/trunk/zh/docs/loss.html (added)
+++ incubator/singa/site/trunk/zh/docs/loss.html Fri Jun  8 15:29:00 2018
@@ -0,0 +1,411 @@
+
+
+
+<!DOCTYPE html>
+<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
+<head>
+  <meta charset="utf-8">
+  
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  
+  <title>损失(Loss) &mdash; incubator-singa 1.1.0 documentation</title>
+  
+
+  
+  
+  
+  
+
+  
+
+  
+  
+    
+
+  
+
+  
+    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
+  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+    <link rel="index" title="Index" href="../genindex.html" />
+    <link rel="search" title="Search" href="../search.html" />
+    <link rel="next" title="度量(Metric)" href="metric.html" />
+    <link rel="prev" title="初始化器(Initializer)" href="initializer.html" 
/>
+    <link href="../_static/style.css" rel="stylesheet" type="text/css">
+    <!--link href="../_static/fontawesome-all.min.css" rel="stylesheet" 
type="text/css"-->
+       <link rel="stylesheet" 
href="https://use.fontawesome.com/releases/v5.0.13/css/all.css"; 
integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp"
 crossorigin="anonymous">
+    <style>
+       .fa:hover {
+           opacity: 0.7;
+       }
+       .fab:hover {
+           opacity: 0.7;
+       }
+    </style>
+
+
+  
+  <script src="../_static/js/modernizr.min.js"></script>
+
+</head>
+
+<body class="wy-body-for-nav">
+
+   
+  <div class="wy-grid-for-nav">
+
+    
+    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
+      <div class="wy-side-scroll">
+        <div class="wy-side-nav-search">
+          
+
+          
+            <a href="../index.html" class="icon icon-home"> incubator-singa
+          
+
+          
+            
+            <img src="../_static/singa.png" class="logo" alt="Logo"/>
+          
+          </a>
+
+          
+            
+            
+              <div class="version">
+                latest
+              </div>
+            
+          
+
+          
+<div role="search">
+  <form id="rtd-search-form" class="wy-form" action="../search.html" 
method="get">
+    <input type="text" name="q" placeholder="Search docs" />
+    <input type="hidden" name="check_keywords" value="yes" />
+    <input type="hidden" name="area" value="default" />
+  </form>
+</div>
+
+          
+        </div>
+
+        <div class="wy-menu wy-menu-vertical" data-spy="affix" 
role="navigation" aria-label="main navigation">
+          
+            
+            
+              
+            
+            
+              <ul class="current">
+<li class="toctree-l1"><a class="reference internal" 
href="../downloads.html">下载 SINGA</a></li>
+<li class="toctree-l1 current"><a class="reference internal" 
href="index.html">文档</a><ul class="current">
+<li class="toctree-l2"><a class="reference internal" 
href="installation.html">安装</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="software_stack.html">软件架构</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="device.html">设备(Device)</a></li>
+<li class="toctree-l2"><a class="reference internal" href="tensor.html">å¼ 
量(Tensor)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="layer.html">层(Layer)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="net.html">前馈网络</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="initializer.html">初始化器(Initializer)</a></li>
+<li class="toctree-l2 current"><a class="current reference internal" 
href="#">损失(Loss)</a><ul>
+<li class="toctree-l3"><a class="reference internal" 
href="#class-singa-loss-loss">class singa.loss.Loss</a><ul>
+<li class="toctree-l4"><a class="reference internal" 
href="#backward">backward()</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#evaluate-flag-x-y">evaluate(flag, x, y)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#forward-flag-x-y">forward(flag, x, y)</a></li>
+</ul>
+</li>
+<li class="toctree-l3"><a class="reference internal" 
href="#class-singa-loss-softmaxcrossentropy">class 
singa.loss.SoftmaxCrossEntropy</a></li>
+<li class="toctree-l3"><a class="reference internal" 
href="#class-singa-loss-squarederror">class singa.loss.SquaredError</a><ul>
+<li class="toctree-l4"><a class="reference internal" 
href="#backward">backward()</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#evaluate-flag-x-y">evaluate(flag, x, y)</a></li>
+<li class="toctree-l4"><a class="reference internal" 
href="#forward-flag-x-y">forward(flag, x, y)</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li class="toctree-l2"><a class="reference internal" 
href="metric.html">度量(Metric)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="optimizer.html">优化器(Optimizer)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="data.html">数据(Data)</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="image_tool.html">图像工具</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="snapshot.html">Snapshot</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="utils.html">Utils</a></li>
+<li class="toctree-l2"><a class="reference internal" 
href="model_zoo/index.html">模型库</a></li>
+</ul>
+</li>
+</ul>
+<p class="caption"><span class="caption-text">开发</span></p>
+<ul>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/schedule.html">开发时间表</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/how-contribute.html">如何贡献给 SINGA</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../develop/contribute-code.html">如何贡献代码</a></li>
+</ul>
+<p class="caption"><span class="caption-text">社区</span></p>
+<ul>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/source-repository.html">源代码库</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/mail-lists.html">项目邮件列表</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/issue-tracking.html">问题追踪</a></li>
+<li class="toctree-l1"><a class="reference internal" 
href="../community/team-list.html">SINGA团队</a></li>
+</ul>
+
+            
+          
+        </div>
+      </div>
+    </nav>
+
+    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
+
+      
+      <nav class="wy-nav-top" aria-label="top navigation">
+        
+          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
+          <a href="../index.html">incubator-singa</a>
+        
+      </nav>
+
+
+      <div class="wy-nav-content">
+        
+        <div class="rst-content">
+        
+          
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<div role="navigation" aria-label="breadcrumbs navigation">
+
+  <ul class="wy-breadcrumbs">
+    
+      <li><a href="../index.html">Docs</a> &raquo;</li>
+        
+          <li><a href="index.html">文档</a> &raquo;</li>
+        
+      <li>损失(Loss)</li>
+    
+    
+      <li class="wy-breadcrumbs-aside">
+        
+            
+        
+      </li>
+    
+  </ul>
+
+  
+  <hr/>
+</div>
+          <div role="main" class="document" itemscope="itemscope" 
itemtype="http://schema.org/Article";>
+           <div itemprop="articleBody">
+            
+  <div class="section" id="loss">
+<span id="loss"></span><h1>损失(Loss)<a class="headerlink" href="#loss" 
title="Permalink to this headline">¶</a></h1>
+<p>损失模块包括一组训练损失实例。 有些是从C 
++实现转换而来的,其余的都是直接使用python 
Tensor实现的。</p>
+<p>示例用法:</p>
+<div class="highlight-python notranslate"><div 
class="highlight"><pre><span></span><span class="kn">from</span> <span 
class="nn">singa</span> <span class="kn">import</span> <span 
class="n">tensor</span>
+<span class="kn">from</span> <span class="nn">singa</span> <span 
class="kn">import</span> <span class="n">loss</span>
+
+<span class="n">x</span> <span class="o">=</span> <span 
class="n">tensor</span><span class="o">.</span><span 
class="n">Tensor</span><span class="p">((</span><span class="mi">3</span><span 
class="p">,</span> <span class="mi">5</span><span class="p">))</span>
+<span class="n">x</span><span class="o">.</span><span 
class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span 
class="p">,</span> <span class="mi">1</span><span class="p">)</span>  <span 
class="c1"># randomly genearte the prediction activation</span>
+<span class="n">y</span> <span class="o">=</span> <span 
class="n">tensor</span><span class="o">.</span><span 
class="n">from_numpy</span><span class="p">(</span><span 
class="n">np</span><span class="o">.</span><span class="n">array</span><span 
class="p">([</span><span class="mi">0</span><span class="p">,</span> <span 
class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span 
class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span 
class="n">np</span><span class="o">.</span><span class="n">int</span><span 
class="p">))</span>  <span class="c1"># set the truth</span>
+
+<span class="n">f</span> <span class="o">=</span> <span 
class="n">loss</span><span class="o">.</span><span 
class="n">SoftmaxCrossEntropy</span><span class="p">()</span>
+<span class="n">l</span> <span class="o">=</span> <span 
class="n">f</span><span class="o">.</span><span class="n">forward</span><span 
class="p">(</span><span class="bp">True</span><span class="p">,</span> <span 
class="n">x</span><span class="p">,</span> <span class="n">y</span><span 
class="p">)</span>  <span class="c1"># l is tensor with 3 loss values</span>
+<span class="n">g</span> <span class="o">=</span> <span 
class="n">f</span><span class="o">.</span><span class="n">backward</span><span 
class="p">()</span>  <span class="c1"># g is a tensor containing all gradients 
of x w.r.t l</span>
+</pre></div>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-loss-loss">
+<span id="class-singa-loss-loss"></span><h2>class singa.loss.Loss<a 
class="headerlink" href="#class-singa-loss-loss" title="Permalink to this 
headline">¶</a></h2>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">object</span></code></p>
+<p>损失类的基类</p>
+<p>封装
C++损失类的子类可以使用此基类继承的forward,backward和evaluate函数。
 其他子类需要重写这些函数</p>
+<div class="section" id="backward">
+<span id="backward"></span><h3>backward()<a class="headerlink" 
href="#backward" title="Permalink to this headline">¶</a></h3>
+<p><strong>返回值:</strong> 与损失相对应的梯度</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="evaluate-flag-x-y">
+<span id="evaluate-flag-x-y"></span><h3>evaluate(flag, x, y)<a 
class="headerlink" href="#evaluate-flag-x-y" title="Permalink to this 
headline">¶</a></h3>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag (int)</strong> – 必须是kEval</li>
+<li><strong>x (Tensor)</strong> – 预测Tensor</li>
+<li><strong>y (Tensor)</strong> – 真实Tensor</li>
+</ul>
+<p><strong>返回值:</strong> 所有样本的平均损失</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="forward-flag-x-y">
+<span id="forward-flag-x-y"></span><h3>forward(flag, x, y)<a 
class="headerlink" href="#forward-flag-x-y" title="Permalink to this 
headline">¶</a></h3>
+<p>计算损失值</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag</strong> – 
kTrain/kEval或布尔值。如果是kTrain/True,那么在下一次调用forward前会å
…ˆè°ƒç”¨backward计算梯度。</li>
+<li><strong>x (Tensor)</strong> – 预测Tensor</li>
+<li><strong>y (Tensor)</strong> – 真实Tensor, x.shape[0]必
须和y.shape[0]相同</li>
+</ul>
+<p><strong>返回值:</strong> tensor,每个æ 
·æœ¬å¯¹åº”一个浮点型损失值</p>
+</div>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-loss-softmaxcrossentropy">
+<span id="class-singa-loss-softmaxcrossentropy"></span><h2>class 
singa.loss.SoftmaxCrossEntropy<a class="headerlink" 
href="#class-singa-loss-softmaxcrossentropy" title="Permalink to this 
headline">¶</a></h2>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.loss.Loss</span></code></p>
+<p>此损失函数是SoftMax和交叉熵损失的结合。它通过SoftMax函数转换输å
…¥ï¼Œç„¶åŽæ ¹æ®çœŸå®žå€¼è®¡ç®—交叉熵损失。 对于每个æ 
·æœ¬ï¼ŒçœŸå®žå€¼å¯ä»¥æ˜¯ä¸€ä¸ªæ•´æ•°ä½œä¸ºæ ‡ç­¾ç´¢å¼•; 
或二进制数组,指示标签分布。 因
此,真实值可以是1维或2ç»´tensor。 对于一批æ 
·å“ï¼Œæ•°æ®/特征tensor可以是1维(对于单个æ 
·å“ï¼‰æˆ–2维(对于一组样本)。</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="class-singa-loss-squarederror">
+<span id="class-singa-loss-squarederror"></span><h2>class 
singa.loss.SquaredError<a class="headerlink" 
href="#class-singa-loss-squarederror" title="Permalink to this 
headline">¶</a></h2>
+<p>基类:<code class="docutils literal notranslate"><span 
class="pre">singa.loss.Loss</span></code></p>
+<p>此损失用来衡量预测值和真实值之间的平方差。它通过Python
 Tensor操作实现。</p>
+<hr class="docutils" />
+<div class="section" id="backward">
+<span id="id1"></span><h3>backward()<a class="headerlink" href="#backward" 
title="Permalink to this headline">¶</a></h3>
+<p>计算与损失相对应变量的梯度。</p>
+<p><strong>返回值:</strong> x - y</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="evaluate-flag-x-y">
+<span id="id2"></span><h3>evaluate(flag, x, y)<a class="headerlink" 
href="#evaluate-flag-x-y" title="Permalink to this headline">¶</a></h3>
+<p>计算平均误差。</p>
+<p><strong>返回值:</strong> 浮点型数</p>
+</div>
+<hr class="docutils" />
+<div class="section" id="forward-flag-x-y">
+<span id="id3"></span><h3>forward(flag, x, y)<a class="headerlink" 
href="#forward-flag-x-y" title="Permalink to this headline">¶</a></h3>
+<p>通过0.5 * ||x-y||^2计算损失。</p>
+<p><strong>参数:</strong></p>
+<ul class="simple">
+<li><strong>flag (int)</strong> – 
kTrain或kEval;如果是kTrain,那么在下一次调用forward前会å…
ˆè°ƒç”¨backward计算梯度。</li>
+<li><strong>x (Tensor)</strong> – 预测Tensor</li>
+<li><strong>y (Tensor)</strong> – 真实Tensor, 每个æ 
·æœ¬å¯¹åº”一个整型数, 取值为[0, x.shape[1])。</li>
+</ul>
+<p><strong>返回值:</strong> tensor,每个样本对应一个损失值</p>
+<hr class="docutils" />
+</div>
+</div>
+</div>
+
+
+           </div>
+           
+          </div>
+          <footer>
+  
+    <div class="rst-footer-buttons" role="navigation" aria-label="footer 
navigation">
+      
+        <a href="metric.html" class="btn btn-neutral float-right" 
title="度量(Metric)" accesskey="n" rel="next">Next <span class="fa 
fa-arrow-circle-right"></span></a>
+      
+      
+        <a href="initializer.html" class="btn btn-neutral" 
title="初始化器(Initializer)" accesskey="p" rel="prev"><span class="fa 
fa-arrow-circle-left"></span> Previous</a>
+      
+    </div>
+  
+
+  <hr/>
+
+  <div role="contentinfo">
+    <p>
+        &copy; Copyright 2018 The Apache Software Foundation. All rights 
reserved. Apache SINGA, Apache, the Apache feather logo, and the Apache SINGA 
project logos are trademarks of The Apache Software Foundation. All other marks 
mentioned may be trademarks or registered trademarks of their respective 
owners..
+
+    </p>
+  </div>
+  Built with <a href="http://sphinx-doc.org/";>Sphinx</a> using a <a 
href="https://github.com/rtfd/sphinx_rtd_theme";>theme</a> provided by <a 
href="https://readthedocs.org";>Read the Docs</a>. 
+
+</footer>
+
+        </div>
+      </div>
+
+    </section>
+
+  </div>
+  
+
+
+  
+
+    <script type="text/javascript">
+        var DOCUMENTATION_OPTIONS = {
+            URL_ROOT:'../',
+            VERSION:'1.1.0',
+            LANGUAGE:'None',
+            COLLAPSE_INDEX:false,
+            FILE_SUFFIX:'.html',
+            HAS_SOURCE:  true,
+            SOURCELINK_SUFFIX: '.txt'
+        };
+    </script>
+      <script type="text/javascript" src="../_static/jquery.js"></script>
+      <script type="text/javascript" src="../_static/underscore.js"></script>
+      <script type="text/javascript" src="../_static/doctools.js"></script>
+
+  
+
+  
+  
+    <script type="text/javascript" src="../_static/js/theme.js"></script>
+  
+
+  <script type="text/javascript">
+      jQuery(function () {
+          SphinxRtdTheme.Navigation.enable(true);
+      });
+  </script>
+
+<div class="rst-versions" data-toggle="rst-versions" role="note" 
aria-label="versions">
+  <span class="rst-current-version" data-toggle="rst-current-version">
+    <span class="fa fa-book"> incubator-singa </span>
+    v: latest
+    <span class="fa fa-caret-down"></span>
+  </span>
+  <div class="rst-other-versions">
+      <dl>
+          <dt>Languages</dt>
+          <dd><a href="../../en/index.html">English</a></dd>
+          <dd><a href="../../zh/index.html">中文</a></dd>
+      </dl>
+      <dl>
+          <dt>Versions</dt>
+          <dd><a href="http://singa.apache.org/v0.3.0/";>0.3</a></dd>
+          <dd><a href="http://singa.apache.org/v1.1.0/";>1.1</a></dd>
+      </dl>
+
+  </div>
+  <a href="http://incubator.apache.org/";> <img src= "../_static/apache.png" 
style="background-color:white;"> </a>
+
+  <a href="https://github.com/apache/incubator-singa"; class="fa fa-github" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a 
href="https://aws.amazon.com/marketplace/seller-profile?id=5bcac385-12c4-4802-aec7-351e09b77b4c";
 class="fab fa-aws" style="padding: 10px; font-size: 20px; width: 30px; 
text-align: center; text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://hub.docker.com/r/nusdbsystem/singa/"; class="fab fa-docker" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a> 
+  <a href="https://www.linkedin.com/groups/13550034"; class="fa fa-linkedin" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://twitter.com/ApacheSinga"; class="fa fa-twitter" 
style="padding: 10px; font-size: 20px; width: 30px; text-align: center; 
text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://www.facebook.com/Apache-SINGA-347284219056544/"; class="fa 
fa-facebook" style="padding: 10px; font-size: 20px; width: 30px; text-align: 
center; text-decoration: none; margin: 5px 2px;"></a>
+  <a href="https://www.researchgate.net/project/Apache-SINGA"; class="fab 
fa-researchgate" style="padding: 10px; font-size: 20px; width: 30px; 
text-align: center; text-decoration: none; margin: 5px 2px;"></a>
+
+</div>
+
+ <a href="https://github.com/apache/incubator-singa";>
+    <img style="position: absolute; top: 0; right: 0; border: 0; z-index: 
10000;"
+        
src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png";
+        alt="Fork me on GitHub">
+</a>
+
+ 
+
+
+</body>
+</html>
\ No newline at end of file


Reply via email to