@@ -2985,8 +2985,10 @@ def img_cmrnorm_layer(input,
2985
2985
layer_attr = None ):
2986
2986
"""
2987
2987
Response normalization across feature maps.
2988
- The details please refer to
2989
- `Alex's paper <http://www.cs.toronto.edu/~fritz/absps/imagenet.pdf>`_.
2988
+
2989
+ Reference:
2990
+ ImageNet Classification with Deep Convolutional Neural Networks
2991
+ http://www.cs.toronto.edu/~fritz/absps/imagenet.pdf
2990
2992
2991
2993
The example usage is:
2992
2994
@@ -2995,7 +2997,7 @@ def img_cmrnorm_layer(input,
2995
2997
norm = img_cmrnorm_layer(input=net, size=5)
2996
2998
2997
2999
:param name: The name of this layer. It is optional.
2998
- :type name: None | basestring
3000
+ :type name: basestring
2999
3001
:param input: The input of this layer.
3000
3002
:type input: LayerOutput
3001
3003
:param size: Normalize in number of :math:`size` feature maps.
@@ -3004,9 +3006,11 @@ def img_cmrnorm_layer(input,
3004
3006
:type scale: float
3005
3007
:param power: The hyper-parameter.
3006
3008
:type power: float
3007
- :param num_channels: input layer's filers number or channels. If
3008
- num_channels is None, it will be set automatically.
3009
- :param layer_attr: Extra Layer Attribute.
3009
+ :param num_channels: The number of input channels. If the parameter is not set or
3010
+ set to None, its actual value will be automatically set to
3011
+ the channels number of the input.
3012
+ :param layer_attr: The extra layer attributes. See ExtraLayerAttribute for
3013
+ details.
3010
3014
:type layer_attr: ExtraLayerAttribute
3011
3015
:return: LayerOutput object.
3012
3016
:rtype: LayerOutput
@@ -3034,7 +3038,7 @@ def batch_norm_layer(input,
3034
3038
use_global_stats = None ,
3035
3039
mean_var_names = None ):
3036
3040
"""
3037
- Batch Normalization Layer. The notation of this layer as follow .
3041
+ Batch Normalization Layer. The notation of this layer is as follows .
3038
3042
3039
3043
:math:`x` is the input features over a mini-batch.
3040
3044
@@ -3048,8 +3052,10 @@ def batch_norm_layer(input,
3048
3052
\\ sigma_{\\ beta}^{2} + \\ epsilon}} \\ qquad &//\ normalize \\ \\
3049
3053
y_i &\\ gets \\ gamma \\ hat{x_i} + \\ beta \\ qquad &//\ scale\ and\ shift
3050
3054
3051
- The details of batch normalization please refer to this
3052
- `paper <http://arxiv.org/abs/1502.03167>`_.
3055
+ Reference:
3056
+ Batch Normalization: Accelerating Deep Network Training by Reducing
3057
+ Internal Covariate Shift
3058
+ http://arxiv.org/abs/1502.03167
3053
3059
3054
3060
The example usage is:
3055
3061
@@ -3059,48 +3065,47 @@ def batch_norm_layer(input,
3059
3065
3060
3066
:param name: The name of this layer. It is optional.
3061
3067
:type name: basestring
3062
- :param input: batch normalization input. Better be linear activation.
3063
- Because there is an activation inside batch_normalization.
3068
+ :param input: This layer's input which is to be performed batch normalization on.
3064
3069
:type input: LayerOutput
3065
3070
:param batch_norm_type: We have batch_norm, mkldnn_batch_norm and cudnn_batch_norm.
3066
3071
batch_norm supports CPU, MKLDNN and GPU. cudnn_batch_norm
3067
3072
requires cuDNN version greater or equal to v4 (>=v4).
3068
3073
But cudnn_batch_norm is faster and needs less
3069
3074
memory than batch_norm. mkldnn_batch_norm requires
3070
- enable use_mkldnn. By default (None), we will
3071
- automaticly select cudnn_batch_norm for GPU,
3075
+ use_mkldnn is enabled . By default (None), we will
3076
+ automatically select cudnn_batch_norm for GPU,
3072
3077
mkldnn_batch_norm for MKLDNN and batch_norm for CPU.
3073
- Otherwise, select batch norm type based on the
3074
- specified type. If you use cudnn_batch_norm ,
3075
- we suggested you use latest version, such as v5.1.
3078
+ Users can specify the batch norm type. If you use
3079
+ cudnn_batch_norm, we suggested you use latest version ,
3080
+ such as v5.1.
3076
3081
:type batch_norm_type: None | string, None or "batch_norm" or "cudnn_batch_norm"
3077
3082
or "mkldnn_batch_norm"
3078
- :param act: Activation Type. Better be relu. Because batch
3079
- normalization will normalize input near zero.
3083
+ :param act: Activation type. ReluActivation is the default activation.
3080
3084
:type act: BaseActivation
3081
- :param num_channels: num of image channels or previous layer's number of
3082
- filters. None will automatically get from layer's
3083
- input.
3085
+ :param num_channels: The number of input channels. If the parameter is not set or
3086
+ set to None, its actual value will be automatically set to
3087
+ the channels number of the input.
3084
3088
:type num_channels: int
3085
- :param bias_attr: :math:`\\ beta`, better be zero when initialize. So the
3086
- initial_std=0, initial_mean=1 is best practice.
3089
+ :param bias_attr: :math:`\\ beta`. The bias attribute. If the parameter is set to
3090
+ False or an object whose type is not ParameterAttribute, no
3091
+ bias is defined. If the parameter is set to True, the bias is
3092
+ initialized to zero.
3087
3093
:type bias_attr: ParameterAttribute | None | bool | Any
3088
- :param param_attr: :math:`\\ gamma`, better be one when initialize. So the
3089
- initial_std=0, initial_mean=1 is best practice .
3094
+ :param param_attr: :math:`\\ gamma`. The parameter attribute. See ParameterAttribute
3095
+ for details .
3090
3096
:type param_attr: ParameterAttribute
3091
- :param layer_attr: Extra Layer Attribute.
3097
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
3098
+ details.
3092
3099
:type layer_attr: ExtraLayerAttribute
3093
- :param use_global_stats: whether use moving mean/variance statistics
3094
- during testing peroid. If None or True,
3095
- it will use moving mean/variance statistics during
3096
- testing. If False, it will use the mean
3097
- and variance of current batch of test data for
3098
- testing .
3100
+ :param use_global_stats: Whether use moving mean/variance statistics during
3101
+ testing peroid. If the parameter is set to None or
3102
+ True, it will use moving mean/variance statistics
3103
+ during testing. If the parameter is set to False, it
3104
+ will use the mean and variance of the current batch
3105
+ of test data .
3099
3106
:type use_global_stats: bool | None.
3100
- :param moving_average_fraction: Factor used in the moving average
3101
- computation, referred to as facotr,
3102
- :math:`runningMean = newMean*(1-factor)
3103
- + runningMean*factor`
3107
+ :param moving_average_fraction: Factor used in the moving average computation.
3108
+ :math:`runningMean = newMean*(1-factor) + runningMean*factor`
3104
3109
:type moving_average_fraction: float.
3105
3110
:param mean_var_names: [mean name, variance name]
3106
3111
:type mean_var_names: string list
@@ -3162,8 +3167,9 @@ def sum_to_one_norm_layer(input, name=None, layer_attr=None):
3162
3167
:type input: LayerOutput
3163
3168
:param name: The name of this layer. It is optional.
3164
3169
:type name: basestring
3165
- :param layer_attr: extra layer attributes.
3166
- :type layer_attr: ExtraLayerAttribute.
3170
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute
3171
+ for details.
3172
+ :type layer_attr: ExtraLayerAttribute
3167
3173
:return: LayerOutput object.
3168
3174
:rtype: LayerOutput
3169
3175
"""
@@ -3198,7 +3204,8 @@ def row_l2_norm_layer(input, name=None, layer_attr=None):
3198
3204
:type input: LayerOutput
3199
3205
:param name: The name of this layer. It is optional.
3200
3206
:type name: basestring
3201
- :param layer_attr: extra layer attributes.
3207
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute
3208
+ for details.
3202
3209
:type layer_attr: ExtraLayerAttribute.
3203
3210
:return: LayerOutput object.
3204
3211
:rtype: LayerOutput
@@ -3235,22 +3242,17 @@ def addto_layer(input, act=None, name=None, bias_attr=None, layer_attr=None):
3235
3242
act=ReluActivation(),
3236
3243
bias_attr=False)
3237
3244
3238
- This layer just simply add all input layers together, then activate the sum
3239
- inputs. Each input of this layer should be the same size , which is also the
3240
- output size of this layer.
3245
+ This layer just simply adds all input layers together, then activates the
3246
+ sum. All inputs should share the same dimension , which is also the dimension
3247
+ of this layer's output .
3241
3248
3242
3249
There is no weight matrix for each input, because it just a simple add
3243
3250
operation. If you want a complicated operation before add, please use
3244
3251
mixed_layer.
3245
3252
3246
- It is a very good way to set dropout outside the layers. Since not all
3247
- PaddlePaddle layer support dropout, you can add an add_to layer, set
3248
- dropout here.
3249
- Please refer to dropout_layer for details.
3250
-
3251
3253
:param name: The name of this layer. It is optional.
3252
3254
:type name: basestring
3253
- :param input: Input layers. It could be a LayerOutput or list/tuple of
3255
+ :param input: The input layers. It could be a LayerOutput or list/tuple of
3254
3256
LayerOutput.
3255
3257
:type input: LayerOutput | list | tuple
3256
3258
:param act: Activation Type. LinearActivation is the default activation.
@@ -3259,7 +3261,8 @@ def addto_layer(input, act=None, name=None, bias_attr=None, layer_attr=None):
3259
3261
whose type is not ParameterAttribute, no bias is defined. If the
3260
3262
parameter is set to True, the bias is initialized to zero.
3261
3263
:type bias_attr: ParameterAttribute | None | bool | Any
3262
- :param layer_attr: Extra Layer attribute.
3264
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
3265
+ details.
3263
3266
:type layer_attr: ExtraLayerAttribute
3264
3267
:return: LayerOutput object.
3265
3268
:rtype: LayerOutput
@@ -3298,8 +3301,8 @@ def addto_layer(input, act=None, name=None, bias_attr=None, layer_attr=None):
3298
3301
@layer_support (DROPOUT , ERROR_CLIPPING )
3299
3302
def concat_layer (input , act = None , name = None , layer_attr = None , bias_attr = None ):
3300
3303
"""
3301
- Concat all input vector into one huge vector.
3302
- Inputs can be list of LayerOutput or list of projection.
3304
+ Concatenate all input vectors to one vector.
3305
+ Inputs can be a list of LayerOutput or a list of projection.
3303
3306
3304
3307
The example usage is:
3305
3308
@@ -3309,11 +3312,12 @@ def concat_layer(input, act=None, name=None, layer_attr=None, bias_attr=None):
3309
3312
3310
3313
:param name: The name of this layer. It is optional.
3311
3314
:type name: basestring
3312
- :param input: input layers or projections
3315
+ :param input: The input layers or projections
3313
3316
:type input: list | tuple | collections.Sequence
3314
3317
:param act: Activation type. IdentityActivation is the default activation.
3315
3318
:type act: BaseActivation
3316
- :param layer_attr: Extra Layer Attribute.
3319
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
3320
+ details.
3317
3321
:type layer_attr: ExtraLayerAttribute
3318
3322
:return: LayerOutput object.
3319
3323
:rtype: LayerOutput
@@ -3383,7 +3387,7 @@ def __reduce_concat_type__(a, b):
3383
3387
def seq_concat_layer (a , b , act = None , name = None , layer_attr = None ,
3384
3388
bias_attr = None ):
3385
3389
"""
3386
- Concat sequence a with sequence b.
3390
+ Concatenate sequence a and sequence b.
3387
3391
3388
3392
Inputs:
3389
3393
- a = [a1, a2, ..., am]
@@ -3402,13 +3406,14 @@ def seq_concat_layer(a, b, act=None, name=None, layer_attr=None,
3402
3406
3403
3407
:param name: The name of this layer. It is optional.
3404
3408
:type name: basestring
3405
- :param a: input sequence layer
3409
+ :param a: The first input sequence layer
3406
3410
:type a: LayerOutput
3407
- :param b: input sequence layer
3411
+ :param b: The second input sequence layer
3408
3412
:type b: LayerOutput
3409
3413
:param act: Activation type. IdentityActivation is the default activation.
3410
3414
:type act: BaseActivation
3411
- :param layer_attr: Extra Layer Attribute.
3415
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
3416
+ details.
3412
3417
:type layer_attr: ExtraLayerAttribute
3413
3418
:param bias_attr: The bias attribute. If the parameter is set to False or an object
3414
3419
whose type is not ParameterAttribute, no bias is defined. If the
@@ -3445,58 +3450,57 @@ def memory(name,
3445
3450
boot_bias_active_type = None ,
3446
3451
boot_with_const_id = None ):
3447
3452
"""
3448
- The memory layers is a layer cross each time step. Reference this output
3449
- as previous time step layer :code:`name` 's output.
3453
+ The memory takes a layer's output at previous time step as its own output.
3450
3454
3451
- The default memory is zero in first time step, previous time step's
3452
- output in the rest time steps.
3455
+ If boot_bias, the activation of the bias is the initial value of the memory.
3453
3456
3454
- If boot_bias, the first time step value is this bias and
3455
- with activation .
3457
+ If boot_with_const_id is set, then the memory's output at the first time step
3458
+ is a IndexSlot, the Arguments.ids()[0] is this :code:`cost_id` .
3456
3459
3457
- If boot_with_const_id, then the first time stop is a IndexSlot, the
3458
- Arguments.ids()[0] is this :code:`cost_id` .
3460
+ If boot_layer is specified, the memory's output at the first time step will
3461
+ be the boot_layer's output .
3459
3462
3460
- If boot_layer is not null, the memory is just the boot_layer's output.
3461
- Set :code:`is_seq` is true boot layer is sequence.
3462
-
3463
- The same name layer in recurrent group will set memory on each time
3464
- step.
3463
+ In other case, the default memory's output at the first time step is zero.
3465
3464
3466
3465
.. code-block:: python
3467
3466
3468
3467
mem = memory(size=256, name='state')
3469
3468
state = fc_layer(input=mem, size=256, name='state')
3470
3469
3471
- If you do not want to specify the name, you can equivalently use set_input()
3472
- to specify the layer needs to be remembered as the following:
3470
+ If you do not want to specify the name, you can also use set_input()
3471
+ to specify the layer to be remembered as the following:
3473
3472
3474
3473
.. code-block:: python
3475
3474
3476
3475
mem = memory(size=256)
3477
3476
state = fc_layer(input=mem, size=256)
3478
3477
mem.set_input(mem)
3479
3478
3480
- :param name: the name of the layer which this memory remembers.
3479
+ :param name: The name of the layer which this memory remembers.
3481
3480
If name is None, user should call set_input() to specify the
3482
3481
name of the layer which this memory remembers.
3483
3482
:type name: basestring
3484
- :param size: size of memory.
3483
+ :param size: The dimensionality of memory.
3485
3484
:type size: int
3486
- :param memory_name: the name of the memory.
3487
- It is ignored when name is provided.
3485
+ :param memory_name: The name of the memory. It is ignored when name is provided.
3488
3486
:type memory_name: basestring
3489
3487
:param is_seq: DEPRECATED. is sequence for boot_layer
3490
3488
:type is_seq: bool
3491
- :param boot_layer: boot layer of memory.
3489
+ :param boot_layer: This parameter specifies memory's output at the first time
3490
+ step and the output is boot_layer's output.
3492
3491
:type boot_layer: LayerOutput | None
3493
- :param boot_bias: boot layer's bias
3492
+ :param boot_bias: The bias attribute of memory's output at the first time step.
3493
+ If the parameter is set to False or an object whose type is not
3494
+ ParameterAttribute, no bias is defined. If the parameter is set
3495
+ to True, the bias is initialized to zero.
3494
3496
:type boot_bias: ParameterAttribute | None
3495
- :param boot_bias_active_type: boot layer's active type.
3497
+ :param boot_bias_active_type: Activation type for memory's bias at the first time
3498
+ step. LinearActivation is the default activation.
3496
3499
:type boot_bias_active_type: BaseActivation
3497
- :param boot_with_const_id: boot layer's id.
3500
+ :param boot_with_const_id: This parameter specifies memory's output at the first
3501
+ time step and the output is an index.
3498
3502
:type boot_with_const_id: int
3499
- :return: LayerOutput object which is a memory .
3503
+ :return: LayerOutput object.
3500
3504
:rtype: LayerOutput
3501
3505
"""
3502
3506
if boot_bias_active_type is None :
0 commit comments