Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏有凉风,冬有雪
Paddle
提交
1baeebc8
P
Paddle
项目概览
夏有凉风,冬有雪
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1baeebc8
编写于
11月 14, 2017
作者:
R
ranqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the annotations of layers
上级
9202671d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
113 addition
and
81 deletion
+113
-81
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+113
-81
未找到文件。
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
1baeebc8
...
...
@@ -3573,30 +3573,29 @@ def lstm_step_layer(input,
This layer has two outputs. Default output is :math:`h_t`. The other
output is :math:`o_t`, whose name is 'state' and can use
output is :math:`o_t`, whose name is 'state' and
users
can use
:code:`get_output_layer` to extract this output.
:param name: The name of this layer. It is optional.
:type name: basestring
:param size: Layer's size. NOTE: lstm layer's size, should be equal to
:code:`input.size/4`, and should be equal to
:code:`state.size`.
:param size: The dimension of this layer's output, which must be
equal to the dimension of the state.
:type size: int
:param input:
input layer. :math:`Wx_t + Wh_{t-1}`
:param input:
The input of this layer.
:type input: LayerOutput
:param state:
State Layer. :math:`c_{t-1}`
:param state:
The state of a lstm.
:type state: LayerOutput
:param act: Activation type. TanhActivation is the default.
:type act: BaseActivation
:param gate_act:
Gate Activation Typ
e. SigmoidActivation is the default.
:param gate_act:
Activation type of the gat
e. SigmoidActivation is the default.
:type gate_act: BaseActivation
:param state_act:
State Activation Typ
e. TanhActivation is the default.
:param state_act:
Activation type of the stat
e. TanhActivation is the default.
:type state_act: BaseActivation
:param bias_attr: The bias attribute. If the parameter is set to False or an object
whose type is not ParameterAttribute, no bias is defined. If the
parameter is set to True, the bias is initialized to zero.
:type bias_attr: ParameterAttribute | None | bool | Any
:param layer_attr:
layer's extra attribute
.
:param layer_attr:
The extra layer attribute. See ExtraLayerAttribute for details
.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -3641,22 +3640,29 @@ def gru_step_layer(input,
layer_attr
=
None
):
"""
:param input:
:param input:
The input of this layer, whose dimension can be divided by 3.
:type input: LayerOutput
:param output_mem:
:param size:
:param act:
:param output_mem: A memory which memorizes the output of this layer at previous
time step.
:type output_mem: LayerOutput
:param size: The dimension of this layer's output. If it is not set or set to None,
it will be set to one-third of the dimension of the input automatically.
:type size: int
:param act: Activation type of this layer's output. SigmoidActivation
is the default.
:type act: BaseActivation
:param name: The name of this layer. It is optional.
:type name: basestring
:param gate_act: Activation type of this layer's two gates. Default is Sigmoid.
:type gate_act: BaseActivation
:param bias_attr: The bias attribute. If the parameter is set to False or an object
whose type is not ParameterAttribute, no bias is defined. If the
parameter is set to True, the bias is initialized to zero.
:type bias_attr: ParameterAttribute | None | bool | Any
:param param_attr: the parameter_attribute for transforming the output_mem
from previous step.
:param layer_attr:
:param param_attr: The parameter attribute. See ParameterAttribute for details.
:type param_attr: ParameterAttribute
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for details.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:rtype: LayerOutput
"""
...
...
@@ -3701,24 +3707,33 @@ def gru_step_naive_layer(input,
param_attr
=
None
,
layer_attr
=
None
):
"""
GRU Step Layer, but using MixedLayer to generate. It support ERROR_CLIPPING
GRU Step Layer, but using MixedLayer to generate. It support
s
ERROR_CLIPPING
and DROPOUT.
:param input:
:param output_mem:
:param size:
:param input: The input of this layer, whose dimension can be divided by 3.
:param output_mem: A memory which memorizes the output of this layer at previous
time step.
:type output_mem: LayerOutput
:param size: The dimension of this layer's output. If it is not set or set to None,
it will be set to one-third of the dimension of the input automatically.
:type size: int
:param name: The name of this layer. It is optional.
:param act:
:type name: basestring
:param act: Activation type of this layer's output. SigmoidActivation
is the default.
:type act: BaseActivation
:param gate_act: Activation type of this layer's two gates. Default is Sigmoid.
:param gate_act: Activation type of this layer's two gates. TanhActivation
is the default.
:type gate_act: BaseActivation
:param bias_attr: The bias attribute. If the parameter is set to False or an object
whose type is not ParameterAttribute, no bias is defined. If the
parameter is set to True, the bias is initialized to zero.
:type bias_attr: ParameterAttribute | None | bool | Any
:param param_attr:
:param layer_attr:
:return:
:param param_attr: The parameter attribute. See ParameterAttribute for details.
:type param_attr: ParameterAttribute
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for details.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:rtype: LayerOutput
"""
if
input
.
size
%
3
!=
0
:
...
...
@@ -3780,12 +3795,13 @@ def get_output_layer(input, arg_name, name=None, layer_attr=None):
:param name: The name of this layer. It is optional.
:type name: basestring
:param input:
get output layer's input. And this layer should contains
:param input:
The input layer. And this layer should contain
multiple outputs.
:type input: LayerOutput
:param arg_name:
Output name from input
.
:param arg_name:
The name of the output of the input layer
.
:type arg_name: basestring
:param layer_attr: Layer's extra attribute.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:return: LayerOutput object.
:rtype: LayerOutput
"""
...
...
@@ -3848,11 +3864,13 @@ def recurrent_layer(input,
whose type is not ParameterAttribute, no bias is defined. If the
parameter is set to True, the bias is initialized to zero.
:type bias_attr: ParameterAttribute | None | bool | Any
:param param_attr: parameter attribute.
:param param_attr: The parameter attribute. See ParameterAttribute for
details.
:type param_attr: ParameterAttribute
:param name: The name of this layer. It is optional.
:type name: basestring
:param layer_attr: Layer Attribute.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -3877,7 +3895,7 @@ def recurrent_layer(input,
class
StaticInput
(
object
):
"""
StaticInput is only used in recurrent_group which defines a read-only memory
that
can be a sequence or non-sequence.
and
can be a sequence or non-sequence.
:param size: DEPRECATED
:param is_seq: DEPRECATED
"""
...
...
@@ -3910,7 +3928,7 @@ def recurrent_group(step, input, reverse=False, name=None, targetInlink=None):
Recurrent layer group is an extremely flexible recurrent unit in
PaddlePaddle. As long as the user defines the calculation done within a
time step, PaddlePaddle will iterate such a recurrent calculation over
sequence input. This is extremely useful
l for attention based model
, or
sequence input. This is extremely useful
for attention-based models
, or
Neural Turning Machine like models.
The basic usage (time steps) is:
...
...
@@ -3933,18 +3951,18 @@ def recurrent_group(step, input, reverse=False, name=None, targetInlink=None):
demo/seqToseq/seqToseq_net.py
- sequence steps: paddle/gserver/tests/sequence_nest_layer_group.conf
:param step:
recurrent one time step function.The input of this function is
input of the group. The return of this function will be
recurrent group's return value.
:param step:
A step function which will be executed every step. The input
of this function is the input of the group. The return of
this function will be
recurrent group's return value.
The recurrent group scatter a sequence into time steps. And
for each time step, will invoke step function, and return
a time step result. Then gather
each time step of output
into
The recurrent group scatter
s
a sequence into time steps. And
for each time step,
it
will invoke step function, and return
a time step result. Then gather
outputs of each time step
into
layer group's output.
:type step: callable
:param name:
recurrent_group's name
.
:param name:
The recurrent_group's name. It is optional
.
:type name: basestring
:param input: Input links array.
...
...
@@ -3952,11 +3970,11 @@ def recurrent_group(step, input, reverse=False, name=None, targetInlink=None):
LayerOutput will be scattered into time steps.
SubsequenceInput will be scattered into sequence steps.
StaticInput will be imported to each time step, and doesn't change
through
time. It's a mechanism to access layer outside step function.
over
time. It's a mechanism to access layer outside step function.
:type input: LayerOutput | StaticInput | SubsequenceInput | list | tuple
:param reverse: If reverse is set true, the recurrent unit will process the
:param reverse: If reverse is set t
o T
rue, the recurrent unit will process the
input sequence in a reverse order.
:type reverse: bool
...
...
@@ -4091,7 +4109,8 @@ def maxid_layer(input, name=None, layer_attr=None):
:type input: LayerOutput
:param name: The name of this layer. It is optional.
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -4124,11 +4143,12 @@ def out_prod_layer(input1, input2, name=None, layer_attr=None):
:param name: The name of this layer. It is optional.
:type name: basestring
:param input1: The first input layer
name
.
:param input1: The first input layer.
:type input: LayerOutput
:param input2: The second input layer
name
.
:param input2: The second input layer.
:type input2: LayerOutput
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -4167,9 +4187,10 @@ def eos_layer(input, eos_id, name=None, layer_attr=None):
:type name: basestring
:param input: The input of this layer.
:type input: LayerOutput
:param eos_id:
e
nd id of sequence
:param eos_id:
E
nd id of sequence
:type eos_id: int
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -4230,8 +4251,9 @@ def beam_search(step,
- machine translation : demo/seqToseq/translation/gen.conf
\
demo/seqToseq/seqToseq_net.py
:param name: Name of the recurrent unit that generates sequences.
:type name: base string
:param name: The name of the recurrent unit that generates sequences.
It is optional.
:type name: basestring
:param step: A callable function that defines the calculation in a time
step, and it is applied to sequences with arbitrary length by
sharing a same set of weights.
...
...
@@ -4356,16 +4378,18 @@ def square_error_cost(input,
:param name: The name of this layer. It is optional.
:type name: basestring
:param input:
Network prediction
.
:param input:
The first input layer
.
:type input: LayerOutput
:param label:
Data
label.
:param label:
The input
label.
:type label: LayerOutput
:param weight: The weight
affects the cost, namely the scale of cost.
It is an optional argument
.
:param weight: The weight
layer defines a weight for each sample in the
mini-batch. It is optional
.
:type weight: LayerOutput
:param coeff: The coefficient affects the gradient in the backward.
:param coeff: The weight of the gradient in the back propagation.
1.0 is the default.
:type coeff: float
:param layer_attr: layer's extra attribute.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -4398,17 +4422,20 @@ def classification_cost(input,
:param name: The name of this layer. It is optional.
:type name: basestring
:param input:
input layer name. network output
.
:param input:
The first input layer
.
:type input: LayerOutput
:param label:
label layer name. data_layer often
.
:param label:
The input label
.
:type label: LayerOutput
:param weight: The weight
affects the cost, namely the scale of cost.
It is an optional argument
.
:param weight: The weight
layer defines a weight for each sample in the
mini-batch. It is optional
.
:type weight: LayerOutput
:param evaluator: Evaluator method.
:param layer_attr: layer's extra attribute.
:param evaluator: Evaluator method. classification_error_evaluator is the default.
:type evaluator: Evaluator method
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute
:param coeff: The coefficient affects the gradient in the backward.
:param coeff: The weight of the gradient in the back propagation.
1.0 is the default.
:type coeff: float
:return: LayerOutput object.
:rtype: LayerOutput
...
...
@@ -4461,7 +4488,7 @@ def conv_operator(img,
Different from img_conv_layer, conv_op is an Operator, which can be used
in mixed_layer. And conv_op takes two inputs to perform convolution.
The first input is the image and the second is filter kernel. It only
support GPU mode.
support
s
GPU mode.
The example usage is:
...
...
@@ -4473,27 +4500,31 @@ def conv_operator(img,
num_filters=64,
num_channels=64)
:param img:
input image
:param img:
The input image.
:type img: LayerOutput
:param filter:
input filter
:param filter:
The input filter.
:type filter: LayerOutput
:param filter_size: The
x dimension of a filter kernel
.
:param filter_size: The
dimension of the filter kernel on the x axis
.
:type filter_size: int
:param filter_size_y: The
y dimension of a filter kernel. Since
PaddlePaddle now supports rectangular filters,
the filter's shape can be (filter_size, filter_size_y)
.
:param filter_size_y: The
dimension of the filter kernel on the y axis.
If the parameter is not set or set to None, it will
set to 'filter_size' automatically
.
:type filter_size_y: int
:param num_filters:
channel of output data
.
:param num_filters:
The number of the output channels
.
:type num_filters: int
:param num_channels: channel of input data.
:param num_channels: The number of the input channels. If the parameter is not set
or set to None, it will be automatically set to the channel
number of the 'img'.
:type num_channels: int
:param stride: The
x dimension of the stride
.
:param stride: The
stride on the x axis
.
:type stride: int
:param stride_y: The y dimension of the stride.
:param stride_y: The stride on the y axis. If the parameter is not set or
set to None, it will be set to 'stride' automatically.
:type stride_y: int
:param padding: The
x dimension of padding
.
:param padding: The
padding size on the x axis
.
:type padding: int
:param padding_y: The y dimension of padding.
:param padding_y: The padding size on the y axis. If the parameter is not set
or set to None, it will be set to 'padding' automatically.
:type padding_y: int
:return: A ConvOperator Object.
:rtype: ConvOperator
...
...
@@ -5458,7 +5489,8 @@ def crf_layer(input,
:type label: LayerOutput
:param size: The category number.
:type size: int
:param weight: The scale of the cost of each sample. It is optional.
:param weight: The weight layer defines a weight for each sample in the
mini-batch. It is optional.
:type weight: LayerOutput
:param param_attr: The parameter attribute. See ParameterAttribute for
details.
...
...
@@ -5608,7 +5640,7 @@ def nce_layer(input,
:param label: The input label.
:type label: LayerOutput
:param weight: The weight layer defines a weight for each sample in the
mini-batch.
The default value is None
.
mini-batch.
It is optional
.
:type weight: LayerOutput
:param num_classes: The number of classes.
:type num_classes: int
...
...
@@ -5737,7 +5769,8 @@ def rank_cost(left,
:type right: LayerOutput
:param label: Label is 1 or 0, means positive order and reverse order.
:type label: LayerOutput
:param weight: The scale of cost. It is optional.
:param weight: The weight layer defines a weight for each sample in the
mini-batch. It is optional.
:type weight: LayerOutput
:param name: The name of this layer. It is optional.
:type name: basestring
...
...
@@ -5855,9 +5888,8 @@ def cross_entropy(input,
:param coeff: The weight of the gradient in the back propagation.
1.0 is the default.
:type coeff: float
:param weight: The cost of each sample is multiplied with each weight.
The weight should be a layer with size=1. Note that gradient
will not be calculated for weight.
:param weight: The weight layer defines a weight for each sample in the
mini-batch. It is optional.
:type weight: LayerOutout
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录