Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e4c8de9e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e4c8de9e
编写于
11月 24, 2017
作者:
R
ranqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the annotations of layers.py
上级
2c471db2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
63 addition
and
47 deletion
+63
-47
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+63
-47
未找到文件。
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
e4c8de9e
...
@@ -1900,9 +1900,12 @@ def repeat_layer(input,
...
@@ -1900,9 +1900,12 @@ def repeat_layer(input,
A layer for repeating the input for num_repeats times.
A layer for repeating the input for num_repeats times.
If as_row_vector:
If as_row_vector:
.. math::
.. math::
y = [x_1,\cdots, x_n, \cdots, x_1, \cdots, x_n]
y = [x_1,\cdots, x_n, \cdots, x_1, \cdots, x_n]
If not as_row_vector:
If not as_row_vector:
.. math::
.. math::
y = [x_1,\cdots, x_1, \cdots, x_n, \cdots, x_n]
y = [x_1,\cdots, x_1, \cdots, x_n, \cdots, x_n]
...
@@ -1915,19 +1918,19 @@ def repeat_layer(input,
...
@@ -1915,19 +1918,19 @@ def repeat_layer(input,
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput
:type input: LayerOutput
:param num_repeats:
Repeat the input so many times
:param num_repeats:
The times of repeating the input.
:type num_repeats: int
:type num_repeats: int
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:
param as_row_vector: True for treating input as row vector and repeat
ing
:
type name: basestr
ing
in the column direction. This is equivalent to apply
:param as_row_vector: Whether to treat the input as row vectors or not. If
concat_layer() with num_repeats same input.
the parameter is set to True, the repeating operation
False for treating input as column vector and repeating
will be performed in the column direction. Otherwise,
in the row direction.
i
t will be performed i
n the row direction.
:type as_row_vector: bool
:type as_row_vector: bool
:param act: Activation type. IdentityActivation is the default activation.
:param act: Activation type. IdentityActivation is the default activation.
:type act: BaseActivation
:type act: BaseActivation
:
type name: basestring
:
param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
:param layer_attr: extra layer attribute
s.
detail
s.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -1974,13 +1977,14 @@ def seq_reshape_layer(input,
...
@@ -1974,13 +1977,14 @@ def seq_reshape_layer(input,
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput
:type input: LayerOutput
:param reshape_size:
the size of
reshaped sequence.
:param reshape_size:
The dimension of the
reshaped sequence.
:type reshape_size: int
:type reshape_size: int
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param act: Activation type. IdentityActivation is the default activation.
:param act: Activation type. IdentityActivation is the default activation.
:type act: BaseActivation
:type act: BaseActivation
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:param bias_attr: The bias attribute. If the parameter is set to False or an object
: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
whose type is not ParameterAttribute, no bias is defined. If the
...
@@ -2008,7 +2012,7 @@ def seq_reshape_layer(input,
...
@@ -2008,7 +2012,7 @@ def seq_reshape_layer(input,
@
layer_support
()
@
layer_support
()
def
interpolation_layer
(
input
,
weight
,
name
=
None
,
layer_attr
=
None
):
def
interpolation_layer
(
input
,
weight
,
name
=
None
,
layer_attr
=
None
):
"""
"""
This layer
is for linear interpolation with
two inputs,
This layer
performs linear interpolation on
two inputs,
which is used in NEURAL TURING MACHINE.
which is used in NEURAL TURING MACHINE.
.. math::
.. math::
...
@@ -2030,7 +2034,8 @@ def interpolation_layer(input, weight, name=None, layer_attr=None):
...
@@ -2030,7 +2034,8 @@ def interpolation_layer(input, weight, name=None, layer_attr=None):
:type weight: LayerOutput
:type weight: LayerOutput
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2064,7 +2069,7 @@ def bilinear_interp_layer(input,
...
@@ -2064,7 +2069,7 @@ def bilinear_interp_layer(input,
name
=
None
,
name
=
None
,
layer_attr
=
None
):
layer_attr
=
None
):
"""
"""
This layer i
s to implement bilinear interpolation on conv layer
output.
This layer i
mplements bilinear interpolation on convolutional layer's
output.
Please refer to Wikipedia: https://en.wikipedia.org/wiki/Bilinear_interpolation
Please refer to Wikipedia: https://en.wikipedia.org/wiki/Bilinear_interpolation
...
@@ -2074,15 +2079,16 @@ def bilinear_interp_layer(input,
...
@@ -2074,15 +2079,16 @@ def bilinear_interp_layer(input,
bilinear = bilinear_interp_layer(input=layer1, out_size_x=64, out_size_y=64)
bilinear = bilinear_interp_layer(input=layer1, out_size_x=64, out_size_y=64)
:param
input: A input
layer.
:param
input: The input of this
layer.
:type input: LayerOutput.
:type input: LayerOutput.
:param out_size_x: bilinear interpolation output width.
:param out_size_x: The width of the output.
:type out_size_x: int | None
:type out_size_x: int
:param out_size_y: bilinear interpolation output height.
:param out_size_y: The height of the output.
:type out_size_y: int | None
:type out_size_y: int
:param name: The layer's name, which cna not be specified.
:param name: The name of this layer. It is optional.
:type name: None | basestring
:type name: basestring
:param layer_attr: Extra Layer attribute.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2120,8 +2126,8 @@ def power_layer(input, weight, name=None, layer_attr=None):
...
@@ -2120,8 +2126,8 @@ def power_layer(input, weight, name=None, layer_attr=None):
.. math::
.. math::
y = x^w
y = x^w
where :math:`x` is a
input vector, :math:`w` is scalar weigh
t,
where :math:`x` is a
n input vector, :math:`w` is a scalar exponen
t,
and :math:`y` is a output vector.
and :math:`y` is a
n
output vector.
The example usage is:
The example usage is:
...
@@ -2131,11 +2137,12 @@ def power_layer(input, weight, name=None, layer_attr=None):
...
@@ -2131,11 +2137,12 @@ def power_layer(input, weight, name=None, layer_attr=None):
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput
:type input: LayerOutput
:param weight:
Weight lay
er.
:param weight:
The exponent of the pow
er.
:type weight: LayerOutput
:type weight: LayerOutput
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2175,11 +2182,12 @@ def scaling_layer(input, weight, name=None, layer_attr=None):
...
@@ -2175,11 +2182,12 @@ def scaling_layer(input, weight, name=None, layer_attr=None):
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput
:type input: LayerOutput
:param weight:
Weight layer
.
:param weight:
The weight of each sample
.
:type weight: LayerOutput
:type weight: LayerOutput
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2217,7 +2225,8 @@ def trans_layer(input, name=None, layer_attr=None):
...
@@ -2217,7 +2225,8 @@ def trans_layer(input, name=None, layer_attr=None):
:type input: LayerOutput
:type input: LayerOutput
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2253,11 +2262,14 @@ def rotate_layer(input, height, width, name=None, layer_attr=None):
...
@@ -2253,11 +2262,14 @@ def rotate_layer(input, height, width, name=None, layer_attr=None):
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput
:type input: LayerOutput
:param height: The height of the sample matrix
:param height: The height of the sample matrix
.
:type height: int
:type height: int
:param width: The width of the sample matrix.
:type width: int
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param layer_attr: extra layer attributes.
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
details.
:type layer_attr: ExtraLayerAttribute.
:type layer_attr: ExtraLayerAttribute.
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2302,15 +2314,15 @@ def cos_sim(a, b, scale=1, size=1, name=None, layer_attr=None):
...
@@ -2302,15 +2314,15 @@ def cos_sim(a, b, scale=1, size=1, name=None, layer_attr=None):
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param a:
input layer a
:param a:
The first input of this layer.
:type a: LayerOutput
:type a: LayerOutput
:param b:
input layer b
:param b:
The second input of this layer.
:type b: LayerOutput
:type b: LayerOutput
:param scale:
scale for cosine value. default is 5
.
:param scale:
The scale of the cosine similarity. 1 is the default value
.
:type scale: float
:type scale: float
:param size:
layer size
. NOTE size_a * size should equal size_b.
:param size:
The dimension of this layer
. NOTE size_a * size should equal size_b.
:type size: int
:type size: int
:param layer_attr:
Extra Layer Attribute
.
:param layer_attr:
The extra layer attribute. See ExtraLayerAttribute for details
.
:type layer_attr: ExtraLayerAttribute
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -2395,8 +2407,10 @@ def hsigmoid(input,
...
@@ -2395,8 +2407,10 @@ def hsigmoid(input,
"""
"""
Organize the classes into a binary tree. At each node, a sigmoid function
Organize the classes into a binary tree. At each node, a sigmoid function
is used to calculate the probability of belonging to the right branch.
is used to calculate the probability of belonging to the right branch.
This idea is from "F. Morin, Y. Bengio (AISTATS 05):
Hierarchical Probabilistic Neural Network Language Model."
Reference:
`Hierarchical Probabilistic Neural Network Language Model
<http://www.gatsby.ucl.ac.uk/aistats/fullpapers/208.pdf>`_
The example usage is:
The example usage is:
...
@@ -2407,19 +2421,21 @@ def hsigmoid(input,
...
@@ -2407,19 +2421,21 @@ def hsigmoid(input,
:param input: The input of this layer.
:param input: The input of this layer.
:type input: LayerOutput | list | tuple
:type input: LayerOutput | list | tuple
:param label:
Label layer
.
:param label:
The input label
.
:type label: LayerOutput
:type label: LayerOutput
:param num_classes: number of classes.
:param num_classes: The number of classes. And it should be larger than 2. If the parameter
:type num_classes: int | None
is not set or set to None, its actual value will be automatically set to
the number of labels.
:type num_classes: int
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param bias_attr: The bias attribute. If the parameter is set to False or an object
: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
whose type is not ParameterAttribute, no bias is defined. If the
parameter is set to True, the bias is initialized to zero.
parameter is set to True, the bias is initialized to zero.
:type bias_attr: ParameterAttribute | None | bool | Any
:type bias_attr: ParameterAttribute | None | bool | Any
:param param_attr:
Parameter Attribute. None means default parameter
.
:param param_attr:
The parameter attribute. See ParameterAttribute for details
.
:type param_attr: ParameterAttribute
| None
:type param_attr: ParameterAttribute
:param layer_attr:
Extra Layer Attribute
.
:param layer_attr:
The extra layer attribute. See ExtraLayerAttribute for details
.
:type layer_attr: ExtraLayerAttribute
:type layer_attr: ExtraLayerAttribute
:return: LayerOutput object.
:return: LayerOutput object.
:rtype: LayerOutput
:rtype: LayerOutput
...
@@ -4241,7 +4257,7 @@ def dot_prod_layer(input1, input2, name=None, layer_attr=None):
...
@@ -4241,7 +4257,7 @@ def dot_prod_layer(input1, input2, name=None, layer_attr=None):
:param name: The name of this layer. It is optional.
:param name: The name of this layer. It is optional.
:type name: basestring
:type name: basestring
:param input1: The first input layer.
:param input1: The first input layer.
:type input: LayerOutput
:type input
1
: LayerOutput
:param input2: The second input layer.
:param input2: The second input layer.
:type input2: LayerOutput
:type input2: LayerOutput
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录