Skip to content

Commit 51c75a9

Browse files
authored
Merge pull request #5742 from ranqiu92/doc
Update annotations of layers.py
2 parents 55bee85 + b0c88e3 commit 51c75a9

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
@@ -2507,12 +2507,12 @@ def img_conv_layer(input,
25072507
input is raw pixels of image(mono or RGB), or it may be the previous layer's
25082508
num_filters * num_group.
25092509
2510-
There are several group of filter in PaddlePaddle implementation.
2511-
Each group will process some channel of the inputs. For example, if an input
2510+
There are several groups of filters in PaddlePaddle implementation.
2511+
Each group will process some channels of the input. For example, if
25122512
num_channel = 256, group = 4, num_filter=32, the PaddlePaddle will create
2513-
32*4 = 128 filters to process inputs. The channels will be split into 4
2514-
pieces. First 256/4 = 64 channels will process by first 32 filters. The
2515-
rest channels will be processed by rest group of filters.
2513+
32*4 = 128 filters to process the input. The channels will be split into 4
2514+
pieces. First 256/4 = 64 channels will be processed by first 32 filters. The
2515+
rest channels will be processed by the rest groups of filters.
25162516
25172517
The example usage is:
25182518
@@ -2528,53 +2528,68 @@ def img_conv_layer(input,
25282528
:type name: basestring
25292529
:param input: The input of this layer.
25302530
:type input: LayerOutput
2531-
:param filter_size: The x dimension of a filter kernel. Or input a tuple for
2532-
two image dimension.
2531+
:param filter_size: The dimensions of the filter kernel. If the parameter is
2532+
set to one integer, the two dimensions on x and y axises
2533+
will be same when filter_size_y is not set. If it is set
2534+
to a list, the first element indicates the dimension on
2535+
the x axis, and the second is used to specify the dimension
2536+
on the y axis when filter_size_y is not provided.
25332537
:type filter_size: int | tuple | list
2534-
:param filter_size_y: The y dimension of a filter kernel. Since PaddlePaddle
2535-
currently supports rectangular filters, the filter's
2536-
shape will be (filter_size, filter_size_y).
2537-
:type filter_size_y: int | None
2538+
:param filter_size_y: The dimension of the filter kernel on the y axis. If the parameter
2539+
is not set, it will be set automatically according to filter_size.
2540+
:type filter_size_y: int
25382541
:param num_filters: Each filter group's number of filter
25392542
:param act: Activation type. ReluActivation is the default activation.
25402543
:type act: BaseActivation
2541-
:param groups: Group size of filters.
2544+
:param groups: The group number. 1 is the default group number.
25422545
:type groups: int
2543-
:param stride: The x dimension of the stride. Or input a tuple for two image
2544-
dimension.
2546+
:param stride: The strides. If the parameter is set to one integer, the strides
2547+
on x and y axises will be same when stride_y is not set. If it is
2548+
set to a list, the first element indicates the stride on the x axis,
2549+
and the second is used to specify the stride on the y axis when
2550+
stride_y is not provided. 1 is the default value.
25452551
:type stride: int | tuple | list
2546-
:param stride_y: The y dimension of the stride.
2552+
:param stride_y: The stride on the y axis.
25472553
:type stride_y: int
2548-
:param padding: The x dimension of the padding. Or input a tuple for two
2549-
image dimension
2554+
:param padding: The padding sizes. If the parameter is set to one integer, the padding
2555+
sizes on x and y axises will be same when padding_y is not set. If it
2556+
is set to a list, the first element indicates the padding size on the
2557+
x axis, and the second is used to specify the padding size on the y axis
2558+
when padding_y is not provided. 0 is the default padding size.
25502559
:type padding: int | tuple | list
2551-
:param padding_y: The y dimension of the padding.
2560+
:param padding_y: The padding size on the y axis.
25522561
:type padding_y: int
2553-
:param dilation: The x dimension of the dilation. Or input a tuple for two
2554-
image dimension
2562+
:param dilation: The dimensions of the dilation. If the parameter is set to one integer,
2563+
the two dimensions on x and y axises will be same when dilation_y is not
2564+
set. If it is set to a list, the first element indicates the dimension
2565+
on the x axis, and the second is used to specify the dimension on the y
2566+
axis when dilation_y is not provided. 1 is the default dimension.
25552567
:type dilation: int | tuple | list
2556-
:param dilation_y: The y dimension of the dilation.
2568+
:param dilation_y: The dimension of the dilation on the y axis.
25572569
:type dilation_y: int
25582570
:param bias_attr: The bias attribute. If the parameter is set to False or an object
25592571
whose type is not ParameterAttribute, no bias is defined. If the
25602572
parameter is set to True, the bias is initialized to zero.
25612573
:type bias_attr: ParameterAttribute | None | bool | Any
2562-
:param num_channels: number of input channels. If None will be set
2563-
automatically from previous output.
2574+
:param num_channels: The number of input channels. If the parameter is not set or
2575+
set to None, its actual value will be automatically set to
2576+
the channel number of the input.
25642577
:type num_channels: int
2565-
:param param_attr: Convolution param attribute. None means default attribute
2578+
:param param_attr: The parameter attribute. See ParameterAttribute for
2579+
details.
25662580
:type param_attr: ParameterAttribute
2567-
:param shared_biases: Is biases will be shared between filters or not.
2581+
:param shared_biases: Whether biases will be shared between filters or not.
25682582
:type shared_biases: bool
2569-
:param layer_attr: Layer Extra Attribute.
2583+
:param layer_attr: The extra layer attributes. See ExtraLayerAttribute for
2584+
details.
25702585
:type layer_attr: ExtraLayerAttribute
2571-
:param trans: true if it is a convTransLayer, false if it is a convLayer
2586+
:param trans: True if it is a convTransLayer, False if it is a convLayer
25722587
:type trans: bool
2573-
:param layer_type: specify the layer_type, default is None. If trans=True,
2574-
layer_type has to be "exconvt" or "cudnn_convt",
2575-
otherwise layer_type has to be either "exconv" or
2576-
"cudnn_conv"
2577-
:type layer_type: String
2588+
:param layer_type: Specify the layer type. If the dilation's dimension on one axis is
2589+
larger than 1, layer_type has to be "cudnn_conv" or "cudnn_convt".
2590+
If trans=True, layer_type has to be "exconvt" or "cudnn_convt",
2591+
otherwise layer_type has to be either "exconv" or "cudnn_conv".
2592+
:type layer_type: basestring
25782593
:return: LayerOutput object.
25792594
:rtype: LayerOutput
25802595
"""
@@ -2679,7 +2694,7 @@ def img_pool_layer(input,
26792694
"""
26802695
Image pooling Layer.
26812696
2682-
The details of pooling layer, please refer ufldl's pooling_ .
2697+
The details of pooling layer, please refer to ufldl's pooling_ .
26832698
26842699
.. _pooling: http://ufldl.stanford.edu/tutorial/supervised/Pooling/
26852700
@@ -2711,32 +2726,37 @@ def img_pool_layer(input,
27112726
padding_y=2,
27122727
pool_type=MaxPooling())
27132728
2714-
:param padding: pooling padding width.
2729+
:param padding: The padding size on the x axis. 0 is the default padding size.
27152730
:type padding: int
2716-
:param padding_y: pooling padding height. It's equal to padding by default.
2717-
:type padding_y: int | None
2718-
:param name: name of pooling layer
2719-
:type name: basestring.
2731+
:param padding_y: The padding size on the y axis. If the parameter is not set
2732+
or set to None, it will be set to 'padding' automatically.
2733+
:param name: The name of this layer. It is optional.
2734+
:type name: basestring
27202735
:param input: The input of this layer.
27212736
:type input: LayerOutput
2722-
:param pool_size: pooling window width
2737+
:param pool_size: The pooling window length on the x axis.
27232738
:type pool_size: int
2724-
:param pool_size_y: pooling window height. It's eaqual to pool_size by default.
2725-
:type pool_size_y: int | None
2726-
:param num_channels: number of input channel.
2739+
:param pool_size_y: The pooling window length on the y axis. If the parameter is
2740+
not set or set to None, its actual value will be automatically
2741+
set to pool_size.
2742+
:type pool_size_y: int
2743+
:param num_channels: The number of input channels. If the parameter is not set or
2744+
set to None, its actual value will be automatically set to
2745+
the channels number of the input.
27272746
:type num_channels: int
2728-
:param pool_type: pooling type. MaxPooling or AvgPooling. Default is
2729-
MaxPooling.
2747+
:param pool_type: Pooling type. MaxPooling is the default pooling.
27302748
:type pool_type: BasePoolingType
2731-
:param stride: stride width of pooling.
2749+
:param stride: The stride on the x axis. 1 is the default value.
27322750
:type stride: int
2733-
:param stride_y: stride height of pooling. It is equal to stride by default.
2734-
:type stride_y: int | None
2735-
:param layer_attr: Extra Layer attribute.
2751+
:param stride_y: The stride on the y axis. If the parameter is not set or set to
2752+
None, its actual value will be automatically set to 'stride'.
2753+
:type stride_y: int
2754+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2755+
details.
27362756
:type layer_attr: ExtraLayerAttribute
2737-
:param ceil_mode: Wether to use ceil mode to calculate output height and with.
2738-
Defalut is True. If set false, Otherwise use floor.
2739-
2757+
:param ceil_mode: Wether to use the ceil function to calculate output height and width.
2758+
True is the default. If it is set to False, the floor function will
2759+
be used.
27402760
:type ceil_mode: bool
27412761
:return: LayerOutput object.
27422762
:rtype: LayerOutput
@@ -2842,24 +2862,32 @@ def img_pool3d_layer(input,
28422862
28432863
:param padding: pooling padding width.
28442864
:type padding: int | tuple | list
2845-
:param name: name of pooling layer
2865+
:param name: The name of this layer. It is optional.
28462866
:type name: basestring.
28472867
:param input: The input of this layer.
28482868
:type input: LayerOutput
2849-
:param pool_size: pooling window width
2869+
:param pool_size: The pooling window lengths along three axises. If the parameter
2870+
is set to one integer, the three lengths will be same.
28502871
:type pool_size: int | tuple | list
2851-
:param num_channels: number of input channel.
2872+
:param num_channels: The number of input channels. If the parameter is not set or
2873+
set to None, its actual value will be automatically set to
2874+
the channels number of the input.
28522875
:type num_channels: int
2853-
:param pool_type: pooling type. MaxPooling or AvgPooling. Default is
2854-
MaxPooling.
2876+
:param pool_type: Pooling type. MaxPooling is the default pooling.
28552877
:type pool_type: BasePoolingType
2856-
:param stride: stride width of pooling.
2878+
:param stride: The strides of the pooling along three axises. If the parameter
2879+
is set to one integer, the three strides will be same. 1 is the
2880+
default value.
28572881
:type stride: int | tuple | list
2858-
:param layer_attr: Extra Layer attribute.
2882+
:param padding: The sizes of padding along three axises. If the parameter is set to
2883+
one integer, they will be same. 0 is the default padding size.
2884+
:type padding: int | tuple | list
2885+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2886+
details.
28592887
:type layer_attr: ExtraLayerAttribute
2860-
:param ceil_mode: Wether to use ceil mode to calculate output height and with.
2861-
Defalut is True. If set false, Otherwise use floor.
2862-
2888+
:param ceil_mode: Wether to use the ceil function to calculate output height and width.
2889+
True is the default. If it is set to False, the floor function will
2890+
be used.
28632891
:type ceil_mode: bool
28642892
:return: LayerOutput object.
28652893
:rtype: LayerOutput
@@ -2938,9 +2966,11 @@ def spp_layer(input,
29382966
pyramid_height=None,
29392967
layer_attr=None):
29402968
"""
2941-
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition.
2942-
The details please refer to
2943-
`Kaiming He's paper <https://arxiv.org/abs/1406.4729>`_.
2969+
A layer performs spatial pyramid pooling.
2970+
2971+
Reference:
2972+
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
2973+
https://arxiv.org/abs/1406.4729
29442974
29452975
The example usage is:
29462976
@@ -2955,13 +2985,16 @@ def spp_layer(input,
29552985
:type name: basestring
29562986
:param input: The input of this layer.
29572987
:type input: LayerOutput
2958-
:param num_channels: number of input channel.
2988+
:param num_channels: The number of input channels. If the parameter is not set or
2989+
set to None, its actual value will be automatically set to
2990+
the channels number of the input.
29592991
:type num_channels: int
2960-
:param pool_type: Pooling type. MaxPooling or AveragePooling. Default is MaxPooling.
2992+
:param pool_type: Pooling type. MaxPooling is the default pooling.
29612993
:type scale: BasePoolingType
2962-
:param pyramid_height: pyramid height.
2994+
:param pyramid_height: The pyramid height of this pooling.
29632995
:type pyramid_height: int
2964-
:param layer_attr: Extra Layer Attribute.
2996+
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
2997+
details.
29652998
:type layer_attr: ExtraLayerAttribute
29662999
:return: LayerOutput object.
29673000
:rtype: LayerOutput
@@ -4694,7 +4727,7 @@ def conv_projection(input,
46944727
will be same when filter_size_y is not set. If it is set
46954728
to a list, the first element indicates the dimension on
46964729
the x axis, and the second is used to specify the dimension
4697-
on the y axis when filter_size is not provided.
4730+
on the y axis when filter_size_y is not provided.
46984731
:type filter_size: int | tuple | list
46994732
:param filter_size_y: The dimension of the filter kernel on the y axis. If the parameter
47004733
is not set, it will be set automatically according to filter_size.
@@ -7076,7 +7109,7 @@ def img_conv3d_layer(input,
70767109
:type layer_attr: ExtraLayerAttribute
70777110
:param trans: True if it is a convTransLayer, False if it is a convLayer
70787111
:type trans: bool
7079-
:param layer_type: Specify the layer_type. If the parameter is set, it must be "deconv3d"
7112+
:param layer_type: Specify the layer type. If the parameter is set, it must be "deconv3d"
70807113
when trans=True. If not set, it will be automatically set to "deconv3d"
70817114
when trans=True and "conv3d" when trans=False.
70827115
:type layer_type: basestring

0 commit comments

Comments
 (0)