Skip to content

Commit ed516e0

Browse files
authored
Merge pull request #5890 from ranqiu92/doc
Update the annotations of layers.py.
2 parents b28b2f1 + e4c8de9 commit ed516e0

File tree

1 file changed

+63
-47
lines changed
  • python/paddle/trainer_config_helpers

1 file changed

+63
-47
lines changed

python/paddle/trainer_config_helpers/layers.py

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,9 +1900,12 @@ def repeat_layer(input,
19001900
A layer for repeating the input for num_repeats times.
19011901
19021902
If as_row_vector:
1903+
19031904
.. math::
19041905
y = [x_1,\cdots, x_n, \cdots, x_1, \cdots, x_n]
1906+
19051907
If not as_row_vector:
1908+
19061909
.. math::
19071910
y = [x_1,\cdots, x_1, \cdots, x_n, \cdots, x_n]
19081911
@@ -1915,19 +1918,19 @@ def repeat_layer(input,
19151918
19161919
:param input: The input of this layer.
19171920
:type input: LayerOutput
1918-
:param num_repeats: Repeat the input so many times
1921+
:param num_repeats: The times of repeating the input.
19191922
:type num_repeats: int
19201923
:param name: The name of this layer. It is optional.
1921-
:param as_row_vector: True for treating input as row vector and repeating
1922-
in the column direction. This is equivalent to apply
1923-
concat_layer() with num_repeats same input.
1924-
False for treating input as column vector and repeating
1925-
in the row direction.
1924+
:type name: basestring
1925+
:param as_row_vector: Whether to treat the input as row vectors or not. If
1926+
the parameter is set to True, the repeating operation
1927+
will be performed in the column direction. Otherwise,
1928+
it will be performed in the row direction.
19261929
:type as_row_vector: bool
19271930
:param act: Activation type. IdentityActivation is the default activation.
19281931
:type act: BaseActivation
1929-
:type name: basestring
1930-
:param layer_attr: extra layer attributes.
1932+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
1933+
details.
19311934
:type layer_attr: ExtraLayerAttribute.
19321935
:return: LayerOutput object.
19331936
:rtype: LayerOutput
@@ -1974,13 +1977,14 @@ def seq_reshape_layer(input,
19741977
19751978
:param input: The input of this layer.
19761979
:type input: LayerOutput
1977-
:param reshape_size: the size of reshaped sequence.
1980+
:param reshape_size: The dimension of the reshaped sequence.
19781981
:type reshape_size: int
19791982
:param name: The name of this layer. It is optional.
19801983
:type name: basestring
19811984
:param act: Activation type. IdentityActivation is the default activation.
19821985
:type act: BaseActivation
1983-
:param layer_attr: extra layer attributes.
1986+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
1987+
details.
19841988
:type layer_attr: ExtraLayerAttribute.
19851989
:param bias_attr: The bias attribute. If the parameter is set to False or an object
19861990
whose type is not ParameterAttribute, no bias is defined. If the
@@ -2008,7 +2012,7 @@ def seq_reshape_layer(input,
20082012
@layer_support()
20092013
def interpolation_layer(input, weight, name=None, layer_attr=None):
20102014
"""
2011-
This layer is for linear interpolation with two inputs,
2015+
This layer performs linear interpolation on two inputs,
20122016
which is used in NEURAL TURING MACHINE.
20132017
20142018
.. math::
@@ -2030,7 +2034,8 @@ def interpolation_layer(input, weight, name=None, layer_attr=None):
20302034
:type weight: LayerOutput
20312035
:param name: The name of this layer. It is optional.
20322036
:type name: basestring
2033-
:param layer_attr: extra layer attributes.
2037+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2038+
details.
20342039
:type layer_attr: ExtraLayerAttribute.
20352040
:return: LayerOutput object.
20362041
:rtype: LayerOutput
@@ -2064,7 +2069,7 @@ def bilinear_interp_layer(input,
20642069
name=None,
20652070
layer_attr=None):
20662071
"""
2067-
This layer is to implement bilinear interpolation on conv layer output.
2072+
This layer implements bilinear interpolation on convolutional layer's output.
20682073
20692074
Please refer to Wikipedia: https://en.wikipedia.org/wiki/Bilinear_interpolation
20702075
@@ -2074,18 +2079,19 @@ def bilinear_interp_layer(input,
20742079
20752080
bilinear = bilinear_interp_layer(input=layer1, out_size_x=64, out_size_y=64)
20762081
2077-
:param input: A input layer.
2078-
:type input: LayerOutput.
2079-
:param out_size_x: bilinear interpolation output width.
2080-
:type out_size_x: int | None
2081-
:param out_size_y: bilinear interpolation output height.
2082-
:type out_size_y: int | None
2083-
:param name: The layer's name, which cna not be specified.
2084-
:type name: None | basestring
2085-
:param layer_attr: Extra Layer attribute.
2086-
:type layer_attr: ExtraLayerAttribute
2082+
:param input: The input of this layer.
2083+
:type input: LayerOutput.
2084+
:param out_size_x: The width of the output.
2085+
:type out_size_x: int
2086+
:param out_size_y: The height of the output.
2087+
:type out_size_y: int
2088+
:param name: The name of this layer. It is optional.
2089+
:type name: basestring
2090+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2091+
details.
2092+
:type layer_attr: ExtraLayerAttribute
20872093
:return: LayerOutput object.
2088-
:rtype: LayerOutput
2094+
:rtype: LayerOutput
20892095
"""
20902096
assert input.layer_type == LayerType.CONV_LAYER
20912097
assert isinstance(input.activation, LinearActivation)
@@ -2120,8 +2126,8 @@ def power_layer(input, weight, name=None, layer_attr=None):
21202126
.. math::
21212127
y = x^w
21222128
2123-
where :math:`x` is a input vector, :math:`w` is scalar weight,
2124-
and :math:`y` is a output vector.
2129+
where :math:`x` is an input vector, :math:`w` is a scalar exponent,
2130+
and :math:`y` is an output vector.
21252131
21262132
The example usage is:
21272133
@@ -2131,11 +2137,12 @@ def power_layer(input, weight, name=None, layer_attr=None):
21312137
21322138
:param input: The input of this layer.
21332139
:type input: LayerOutput
2134-
:param weight: Weight layer.
2140+
:param weight: The exponent of the power.
21352141
:type weight: LayerOutput
21362142
:param name: The name of this layer. It is optional.
21372143
:type name: basestring
2138-
:param layer_attr: extra layer attributes.
2144+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2145+
details.
21392146
:type layer_attr: ExtraLayerAttribute.
21402147
:return: LayerOutput object.
21412148
:rtype: LayerOutput
@@ -2175,11 +2182,12 @@ def scaling_layer(input, weight, name=None, layer_attr=None):
21752182
21762183
:param input: The input of this layer.
21772184
:type input: LayerOutput
2178-
:param weight: Weight layer.
2185+
:param weight: The weight of each sample.
21792186
:type weight: LayerOutput
21802187
:param name: The name of this layer. It is optional.
21812188
:type name: basestring
2182-
:param layer_attr: extra layer attributes.
2189+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2190+
details.
21832191
:type layer_attr: ExtraLayerAttribute.
21842192
:return: LayerOutput object.
21852193
:rtype: LayerOutput
@@ -2217,7 +2225,8 @@ def trans_layer(input, name=None, layer_attr=None):
22172225
:type input: LayerOutput
22182226
:param name: The name of this layer. It is optional.
22192227
:type name: basestring
2220-
:param layer_attr: extra layer attributes.
2228+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2229+
details.
22212230
:type layer_attr: ExtraLayerAttribute.
22222231
:return: LayerOutput object.
22232232
:rtype: LayerOutput
@@ -2253,11 +2262,14 @@ def rotate_layer(input, height, width, name=None, layer_attr=None):
22532262
22542263
:param input: The input of this layer.
22552264
:type input: LayerOutput
2256-
:param height: The height of the sample matrix
2265+
:param height: The height of the sample matrix.
22572266
:type height: int
2267+
:param width: The width of the sample matrix.
2268+
:type width: int
22582269
:param name: The name of this layer. It is optional.
22592270
:type name: basestring
2260-
:param layer_attr: extra layer attributes.
2271+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2272+
details.
22612273
:type layer_attr: ExtraLayerAttribute.
22622274
:return: LayerOutput object.
22632275
:rtype: LayerOutput
@@ -2302,15 +2314,15 @@ def cos_sim(a, b, scale=1, size=1, name=None, layer_attr=None):
23022314
23032315
:param name: The name of this layer. It is optional.
23042316
:type name: basestring
2305-
:param a: input layer a
2317+
:param a: The first input of this layer.
23062318
:type a: LayerOutput
2307-
:param b: input layer b
2319+
:param b: The second input of this layer.
23082320
:type b: LayerOutput
2309-
:param scale: scale for cosine value. default is 5.
2321+
:param scale: The scale of the cosine similarity. 1 is the default value.
23102322
:type scale: float
2311-
:param size: layer size. NOTE size_a * size should equal size_b.
2323+
:param size: The dimension of this layer. NOTE size_a * size should equal size_b.
23122324
:type size: int
2313-
:param layer_attr: Extra Layer Attribute.
2325+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for details.
23142326
:type layer_attr: ExtraLayerAttribute
23152327
:return: LayerOutput object.
23162328
:rtype: LayerOutput
@@ -2395,8 +2407,10 @@ def hsigmoid(input,
23952407
"""
23962408
Organize the classes into a binary tree. At each node, a sigmoid function
23972409
is used to calculate the probability of belonging to the right branch.
2398-
This idea is from "F. Morin, Y. Bengio (AISTATS 05):
2399-
Hierarchical Probabilistic Neural Network Language Model."
2410+
2411+
Reference:
2412+
`Hierarchical Probabilistic Neural Network Language Model
2413+
<http://www.gatsby.ucl.ac.uk/aistats/fullpapers/208.pdf>`_
24002414
24012415
The example usage is:
24022416
@@ -2407,19 +2421,21 @@ def hsigmoid(input,
24072421
24082422
:param input: The input of this layer.
24092423
:type input: LayerOutput | list | tuple
2410-
:param label: Label layer.
2424+
:param label: The input label.
24112425
:type label: LayerOutput
2412-
:param num_classes: number of classes.
2413-
:type num_classes: int | None
2426+
:param num_classes: The number of classes. And it should be larger than 2. If the parameter
2427+
is not set or set to None, its actual value will be automatically set to
2428+
the number of labels.
2429+
:type num_classes: int
24142430
:param name: The name of this layer. It is optional.
24152431
:type name: basestring
24162432
:param bias_attr: The bias attribute. If the parameter is set to False or an object
24172433
whose type is not ParameterAttribute, no bias is defined. If the
24182434
parameter is set to True, the bias is initialized to zero.
24192435
:type bias_attr: ParameterAttribute | None | bool | Any
2420-
:param param_attr: Parameter Attribute. None means default parameter.
2421-
:type param_attr: ParameterAttribute | None
2422-
:param layer_attr: Extra Layer Attribute.
2436+
:param param_attr: The parameter attribute. See ParameterAttribute for details.
2437+
:type param_attr: ParameterAttribute
2438+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for details.
24232439
:type layer_attr: ExtraLayerAttribute
24242440
:return: LayerOutput object.
24252441
:rtype: LayerOutput
@@ -4241,7 +4257,7 @@ def dot_prod_layer(input1, input2, name=None, layer_attr=None):
42414257
:param name: The name of this layer. It is optional.
42424258
:type name: basestring
42434259
:param input1: The first input layer.
4244-
:type input: LayerOutput
4260+
:type input1: LayerOutput
42454261
:param input2: The second input layer.
42464262
:type input2: LayerOutput
42474263
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for

0 commit comments

Comments
 (0)