Skip to content

Commit b0c88e3

Browse files
author
ranqiu
committed
Update annotations of layers.py
1 parent bf4b532 commit b0c88e3

File tree

1 file changed

+103
-70
lines changed
  • python/paddle/trainer_config_helpers

1 file changed

+103
-70
lines changed

python/paddle/trainer_config_helpers/layers.py

Lines changed: 103 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,12 +2458,12 @@ def img_conv_layer(input,
24582458
input is raw pixels of image(mono or RGB), or it may be the previous layer's
24592459
num_filters * num_group.
24602460
2461-
There are several group of filter in PaddlePaddle implementation.
2462-
Each group will process some channel of the inputs. For example, if an input
2461+
There are several groups of filters in PaddlePaddle implementation.
2462+
Each group will process some channels of the input. For example, if
24632463
num_channel = 256, group = 4, num_filter=32, the PaddlePaddle will create
2464-
32*4 = 128 filters to process inputs. The channels will be split into 4
2465-
pieces. First 256/4 = 64 channels will process by first 32 filters. The
2466-
rest channels will be processed by rest group of filters.
2464+
32*4 = 128 filters to process the input. The channels will be split into 4
2465+
pieces. First 256/4 = 64 channels will be processed by first 32 filters. The
2466+
rest channels will be processed by the rest groups of filters.
24672467
24682468
The example usage is:
24692469
@@ -2479,53 +2479,68 @@ def img_conv_layer(input,
24792479
:type name: basestring
24802480
:param input: The input of this layer.
24812481
:type input: LayerOutput
2482-
:param filter_size: The x dimension of a filter kernel. Or input a tuple for
2483-
two image dimension.
2482+
:param filter_size: The dimensions of the filter kernel. If the parameter is
2483+
set to one integer, the two dimensions on x and y axises
2484+
will be same when filter_size_y is not set. If it is set
2485+
to a list, the first element indicates the dimension on
2486+
the x axis, and the second is used to specify the dimension
2487+
on the y axis when filter_size_y is not provided.
24842488
:type filter_size: int | tuple | list
2485-
:param filter_size_y: The y dimension of a filter kernel. Since PaddlePaddle
2486-
currently supports rectangular filters, the filter's
2487-
shape will be (filter_size, filter_size_y).
2488-
:type filter_size_y: int | None
2489+
:param filter_size_y: The dimension of the filter kernel on the y axis. If the parameter
2490+
is not set, it will be set automatically according to filter_size.
2491+
:type filter_size_y: int
24892492
:param num_filters: Each filter group's number of filter
24902493
:param act: Activation type. ReluActivation is the default activation.
24912494
:type act: BaseActivation
2492-
:param groups: Group size of filters.
2495+
:param groups: The group number. 1 is the default group number.
24932496
:type groups: int
2494-
:param stride: The x dimension of the stride. Or input a tuple for two image
2495-
dimension.
2497+
:param stride: The strides. If the parameter is set to one integer, the strides
2498+
on x and y axises will be same when stride_y is not set. If it is
2499+
set to a list, the first element indicates the stride on the x axis,
2500+
and the second is used to specify the stride on the y axis when
2501+
stride_y is not provided. 1 is the default value.
24962502
:type stride: int | tuple | list
2497-
:param stride_y: The y dimension of the stride.
2503+
:param stride_y: The stride on the y axis.
24982504
:type stride_y: int
2499-
:param padding: The x dimension of the padding. Or input a tuple for two
2500-
image dimension
2505+
:param padding: The padding sizes. If the parameter is set to one integer, the padding
2506+
sizes on x and y axises will be same when padding_y is not set. If it
2507+
is set to a list, the first element indicates the padding size on the
2508+
x axis, and the second is used to specify the padding size on the y axis
2509+
when padding_y is not provided. 0 is the default padding size.
25012510
:type padding: int | tuple | list
2502-
:param padding_y: The y dimension of the padding.
2511+
:param padding_y: The padding size on the y axis.
25032512
:type padding_y: int
2504-
:param dilation: The x dimension of the dilation. Or input a tuple for two
2505-
image dimension
2513+
:param dilation: The dimensions of the dilation. If the parameter is set to one integer,
2514+
the two dimensions on x and y axises will be same when dilation_y is not
2515+
set. If it is set to a list, the first element indicates the dimension
2516+
on the x axis, and the second is used to specify the dimension on the y
2517+
axis when dilation_y is not provided. 1 is the default dimension.
25062518
:type dilation: int | tuple | list
2507-
:param dilation_y: The y dimension of the dilation.
2519+
:param dilation_y: The dimension of the dilation on the y axis.
25082520
:type dilation_y: int
25092521
:param bias_attr: The bias attribute. If the parameter is set to False or an object
25102522
whose type is not ParameterAttribute, no bias is defined. If the
25112523
parameter is set to True, the bias is initialized to zero.
25122524
:type bias_attr: ParameterAttribute | None | bool | Any
2513-
:param num_channels: number of input channels. If None will be set
2514-
automatically from previous output.
2525+
:param num_channels: The number of input channels. If the parameter is not set or
2526+
set to None, its actual value will be automatically set to
2527+
the channel number of the input.
25152528
:type num_channels: int
2516-
:param param_attr: Convolution param attribute. None means default attribute
2529+
:param param_attr: The parameter attribute. See ParameterAttribute for
2530+
details.
25172531
:type param_attr: ParameterAttribute
2518-
:param shared_biases: Is biases will be shared between filters or not.
2532+
:param shared_biases: Whether biases will be shared between filters or not.
25192533
:type shared_biases: bool
2520-
:param layer_attr: Layer Extra Attribute.
2534+
:param layer_attr: The extra layer attributes. See ExtraLayerAttribute for
2535+
details.
25212536
:type layer_attr: ExtraLayerAttribute
2522-
:param trans: true if it is a convTransLayer, false if it is a convLayer
2537+
:param trans: True if it is a convTransLayer, False if it is a convLayer
25232538
:type trans: bool
2524-
:param layer_type: specify the layer_type, default is None. If trans=True,
2525-
layer_type has to be "exconvt" or "cudnn_convt",
2526-
otherwise layer_type has to be either "exconv" or
2527-
"cudnn_conv"
2528-
:type layer_type: String
2539+
:param layer_type: Specify the layer type. If the dilation's dimension on one axis is
2540+
larger than 1, layer_type has to be "cudnn_conv" or "cudnn_convt".
2541+
If trans=True, layer_type has to be "exconvt" or "cudnn_convt",
2542+
otherwise layer_type has to be either "exconv" or "cudnn_conv".
2543+
:type layer_type: basestring
25292544
:return: LayerOutput object.
25302545
:rtype: LayerOutput
25312546
"""
@@ -2628,7 +2643,7 @@ def img_pool_layer(input,
26282643
"""
26292644
Image pooling Layer.
26302645
2631-
The details of pooling layer, please refer ufldl's pooling_ .
2646+
The details of pooling layer, please refer to ufldl's pooling_ .
26322647
26332648
.. _pooling: http://ufldl.stanford.edu/tutorial/supervised/Pooling/
26342649
@@ -2660,32 +2675,37 @@ def img_pool_layer(input,
26602675
padding_y=2,
26612676
pool_type=MaxPooling())
26622677
2663-
:param padding: pooling padding width.
2678+
:param padding: The padding size on the x axis. 0 is the default padding size.
26642679
:type padding: int
2665-
:param padding_y: pooling padding height. It's equal to padding by default.
2666-
:type padding_y: int | None
2667-
:param name: name of pooling layer
2668-
:type name: basestring.
2680+
:param padding_y: The padding size on the y axis. If the parameter is not set
2681+
or set to None, it will be set to 'padding' automatically.
2682+
:param name: The name of this layer. It is optional.
2683+
:type name: basestring
26692684
:param input: The input of this layer.
26702685
:type input: LayerOutput
2671-
:param pool_size: pooling window width
2686+
:param pool_size: The pooling window length on the x axis.
26722687
:type pool_size: int
2673-
:param pool_size_y: pooling window height. It's eaqual to pool_size by default.
2674-
:type pool_size_y: int | None
2675-
:param num_channels: number of input channel.
2688+
:param pool_size_y: The pooling window length on the y axis. If the parameter is
2689+
not set or set to None, its actual value will be automatically
2690+
set to pool_size.
2691+
:type pool_size_y: int
2692+
:param num_channels: The number of input channels. If the parameter is not set or
2693+
set to None, its actual value will be automatically set to
2694+
the channels number of the input.
26762695
:type num_channels: int
2677-
:param pool_type: pooling type. MaxPooling or AvgPooling. Default is
2678-
MaxPooling.
2696+
:param pool_type: Pooling type. MaxPooling is the default pooling.
26792697
:type pool_type: BasePoolingType
2680-
:param stride: stride width of pooling.
2698+
:param stride: The stride on the x axis. 1 is the default value.
26812699
:type stride: int
2682-
:param stride_y: stride height of pooling. It is equal to stride by default.
2683-
:type stride_y: int | None
2684-
:param layer_attr: Extra Layer attribute.
2700+
:param stride_y: The stride on the y axis. If the parameter is not set or set to
2701+
None, its actual value will be automatically set to 'stride'.
2702+
:type stride_y: int
2703+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2704+
details.
26852705
:type layer_attr: ExtraLayerAttribute
2686-
:param ceil_mode: Wether to use ceil mode to calculate output height and with.
2687-
Defalut is True. If set false, Otherwise use floor.
2688-
2706+
:param ceil_mode: Wether to use the ceil function to calculate output height and width.
2707+
True is the default. If it is set to False, the floor function will
2708+
be used.
26892709
:type ceil_mode: bool
26902710
:return: LayerOutput object.
26912711
:rtype: LayerOutput
@@ -2791,24 +2811,32 @@ def img_pool3d_layer(input,
27912811
27922812
:param padding: pooling padding width.
27932813
:type padding: int | tuple | list
2794-
:param name: name of pooling layer
2814+
:param name: The name of this layer. It is optional.
27952815
:type name: basestring.
27962816
:param input: The input of this layer.
27972817
:type input: LayerOutput
2798-
:param pool_size: pooling window width
2818+
:param pool_size: The pooling window lengths along three axises. If the parameter
2819+
is set to one integer, the three lengths will be same.
27992820
:type pool_size: int | tuple | list
2800-
:param num_channels: number of input channel.
2821+
:param num_channels: The number of input channels. If the parameter is not set or
2822+
set to None, its actual value will be automatically set to
2823+
the channels number of the input.
28012824
:type num_channels: int
2802-
:param pool_type: pooling type. MaxPooling or AvgPooling. Default is
2803-
MaxPooling.
2825+
:param pool_type: Pooling type. MaxPooling is the default pooling.
28042826
:type pool_type: BasePoolingType
2805-
:param stride: stride width of pooling.
2827+
:param stride: The strides of the pooling along three axises. If the parameter
2828+
is set to one integer, the three strides will be same. 1 is the
2829+
default value.
28062830
:type stride: int | tuple | list
2807-
:param layer_attr: Extra Layer attribute.
2831+
:param padding: The sizes of padding along three axises. If the parameter is set to
2832+
one integer, they will be same. 0 is the default padding size.
2833+
:type padding: int | tuple | list
2834+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2835+
details.
28082836
:type layer_attr: ExtraLayerAttribute
2809-
:param ceil_mode: Wether to use ceil mode to calculate output height and with.
2810-
Defalut is True. If set false, Otherwise use floor.
2811-
2837+
:param ceil_mode: Wether to use the ceil function to calculate output height and width.
2838+
True is the default. If it is set to False, the floor function will
2839+
be used.
28122840
:type ceil_mode: bool
28132841
:return: LayerOutput object.
28142842
:rtype: LayerOutput
@@ -2887,9 +2915,11 @@ def spp_layer(input,
28872915
pyramid_height=None,
28882916
layer_attr=None):
28892917
"""
2890-
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition.
2891-
The details please refer to
2892-
`Kaiming He's paper <https://arxiv.org/abs/1406.4729>`_.
2918+
A layer performs spatial pyramid pooling.
2919+
2920+
Reference:
2921+
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
2922+
https://arxiv.org/abs/1406.4729
28932923
28942924
The example usage is:
28952925
@@ -2904,13 +2934,16 @@ def spp_layer(input,
29042934
:type name: basestring
29052935
:param input: The input of this layer.
29062936
:type input: LayerOutput
2907-
:param num_channels: number of input channel.
2937+
:param num_channels: The number of input channels. If the parameter is not set or
2938+
set to None, its actual value will be automatically set to
2939+
the channels number of the input.
29082940
:type num_channels: int
2909-
:param pool_type: Pooling type. MaxPooling or AveragePooling. Default is MaxPooling.
2941+
:param pool_type: Pooling type. MaxPooling is the default pooling.
29102942
:type scale: BasePoolingType
2911-
:param pyramid_height: pyramid height.
2943+
:param pyramid_height: The pyramid height of this pooling.
29122944
:type pyramid_height: int
2913-
:param layer_attr: Extra Layer Attribute.
2945+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2946+
details.
29142947
:type layer_attr: ExtraLayerAttribute
29152948
:return: LayerOutput object.
29162949
:rtype: LayerOutput
@@ -4604,7 +4637,7 @@ def conv_projection(input,
46044637
will be same when filter_size_y is not set. If it is set
46054638
to a list, the first element indicates the dimension on
46064639
the x axis, and the second is used to specify the dimension
4607-
on the y axis when filter_size is not provided.
4640+
on the y axis when filter_size_y is not provided.
46084641
:type filter_size: int | tuple | list
46094642
:param filter_size_y: The dimension of the filter kernel on the y axis. If the parameter
46104643
is not set, it will be set automatically according to filter_size.
@@ -6986,7 +7019,7 @@ def img_conv3d_layer(input,
69867019
:type layer_attr: ExtraLayerAttribute
69877020
:param trans: True if it is a convTransLayer, False if it is a convLayer
69887021
:type trans: bool
6989-
:param layer_type: Specify the layer_type. If the parameter is set, it must be "deconv3d"
7022+
:param layer_type: Specify the layer type. If the parameter is set, it must be "deconv3d"
69907023
when trans=True. If not set, it will be automatically set to "deconv3d"
69917024
when trans=True and "conv3d" when trans=False.
69927025
:type layer_type: basestring

0 commit comments

Comments
 (0)