@@ -4495,9 +4495,9 @@ def conv_projection(input,
4495
4495
param_attr = None ,
4496
4496
trans = False ):
4497
4497
"""
4498
- Different from img_conv_layer and conv_op, conv_projection is an Projection,
4499
- which can be used in mixed_layer and conat_layer . It use cudnn to implement
4500
- conv and only support GPU mode.
4498
+ Different from img_conv_layer and conv_op, conv_projection is a Projection,
4499
+ which can be used in mixed_layer and concat_layer . It uses cudnn to implement
4500
+ convolution and only supports GPU mode.
4501
4501
4502
4502
The example usage is:
4503
4503
@@ -4510,32 +4510,45 @@ def conv_projection(input,
4510
4510
4511
4511
:param input: The input of this layer.
4512
4512
:type input: LayerOutput
4513
- :param filter_size: The x dimension of a filter kernel.
4514
- :type filter_size: int
4515
- :param filter_size_y: The y dimension of a filter kernel. Since
4516
- PaddlePaddle now supports rectangular filters,
4517
- the filter's shape can be (filter_size, filter_size_y).
4513
+ :param filter_size: The dimensions of the filter kernel. If the parameter is
4514
+ set to one integer, the two dimensions on x and y axises
4515
+ will be same when filter_size_y is not set. If it is set
4516
+ to a list, the first element indicates the dimension on
4517
+ the x axis, and the second is used to specify the dimension
4518
+ on the y axis when filter_size is not provided.
4519
+ :type filter_size: int | tuple | list
4520
+ :param filter_size_y: The dimension of the filter kernel on the y axis. If the parameter
4521
+ is not set, it will be set automatically according to filter_size.
4518
4522
:type filter_size_y: int
4519
- :param num_filters: channel of output data .
4523
+ :param num_filters: The number of filters .
4520
4524
:type num_filters: int
4521
- :param num_channels: channel of input data .
4525
+ :param num_channels: The number of the input channels .
4522
4526
:type num_channels: int
4523
- :param stride: The x dimension of the stride.
4524
- :type stride: int
4525
- :param stride_y: The y dimension of the stride.
4527
+ :param stride: The strides. If the parameter is set to one integer, the strides
4528
+ on x and y axises will be same when stride_y is not set. If it is
4529
+ set to a list, the first element indicates the stride on the x axis,
4530
+ and the second is used to specify the stride on the y axis when
4531
+ stride_y is not provided.
4532
+ :type stride: int | tuple | list
4533
+ :param stride_y: The stride on the y axis.
4526
4534
:type stride_y: int
4527
- :param padding: The x dimension of padding.
4528
- :type padding: int
4529
- :param padding_y: The y dimension of padding.
4535
+ :param padding: The padding sizes. If the parameter is set to one integer, the padding
4536
+ sizes on x and y axises will be same when padding_y is not set. If it
4537
+ is set to a list, the first element indicates the padding size on the
4538
+ x axis, and the second is used to specify the padding size on the y axis
4539
+ when padding_y is not provided.
4540
+ :type padding: int | tuple | list
4541
+ :param padding_y: The padding size on the y axis.
4530
4542
:type padding_y: int
4531
4543
:param groups: The group number.
4532
4544
:type groups: int
4533
- :param param_attr: Convolution param attribute. None means default attribute
4545
+ :param param_attr: The parameter attribute of the convolution. See ParameterAttribute for
4546
+ details.
4534
4547
:type param_attr: ParameterAttribute
4535
- :param trans: whether it is convTrans or conv
4548
+ :param trans: Whether it is ConvTransProjection or ConvProjection
4536
4549
:type trans: bool
4537
- :return: A DotMulProjection Object.
4538
- :rtype: DotMulProjection
4550
+ :return: A Projection Object.
4551
+ :rtype: ConvTransProjection | ConvProjection
4539
4552
"""
4540
4553
if num_channels is None :
4541
4554
assert input .num_filters is not None
@@ -4600,13 +4613,13 @@ def pad_layer(input,
4600
4613
layer_attr = None ):
4601
4614
"""
4602
4615
This operation pads zeros to the input data according to pad_c,pad_h
4603
- and pad_w. pad_c, pad_h, pad_w specifies the which dimension and size
4604
- of padding . And the input data shape is NCHW.
4616
+ and pad_w. pad_c, pad_h, pad_w specify the size in the corresponding
4617
+ dimension . And the input data shape is NCHW.
4605
4618
4606
- For example, pad_c=[2,3] means padding 2 zeros before the
4607
- input data and 3 zeros after the input data in channel dimension.
4608
- pad_h means padding zeros in height dimension. pad_w means padding zeros
4609
- in width dimension.
4619
+ For example, pad_c=[2,3] means padding 2 zeros before the input data
4620
+ and 3 zeros after the input data in the channel dimension. pad_h means
4621
+ padding zeros in the height dimension. pad_w means padding zeros in the
4622
+ width dimension.
4610
4623
4611
4624
For example,
4612
4625
@@ -4643,13 +4656,14 @@ def pad_layer(input,
4643
4656
4644
4657
:param input: The input of this layer.
4645
4658
:type input: LayerOutput
4646
- :param pad_c: padding size in channel dimension.
4659
+ :param pad_c: The padding size in the channel dimension.
4647
4660
:type pad_c: list | None
4648
- :param pad_h: padding size in height dimension.
4661
+ :param pad_h: The padding size in the height dimension.
4649
4662
:type pad_h: list | None
4650
- :param pad_w: padding size in width dimension.
4663
+ :param pad_w: The padding size in the width dimension.
4651
4664
:type pad_w: list | None
4652
- :param layer_attr: Extra Layer Attribute.
4665
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4666
+ details.
4653
4667
:type layer_attr: ExtraLayerAttribute
4654
4668
:param name: The name of this layer. It is optional.
4655
4669
:type name: basestring
@@ -4698,7 +4712,7 @@ def pad_layer(input,
4698
4712
@layer_support ()
4699
4713
def conv_shift_layer (a , b , name = None , layer_attr = None ):
4700
4714
"""
4701
- This layer performs cyclic convolution for two input . For example:
4715
+ This layer performs cyclic convolution on two inputs . For example:
4702
4716
- a[in]: contains M elements.
4703
4717
- b[in]: contains N elements (N should be odd).
4704
4718
- c[out]: contains M elements.
@@ -4707,7 +4721,7 @@ def conv_shift_layer(a, b, name=None, layer_attr=None):
4707
4721
4708
4722
c[i] = \sum_{j=-(N-1)/2}^{(N-1)/2}a_{i+j} * b_{j}
4709
4723
4710
- In this formular :
4724
+ In this formula :
4711
4725
- a's index is computed modulo M. When it is negative, then get item from
4712
4726
the right side (which is the end of array) to the left.
4713
4727
- b's index is computed modulo N. When it is negative, then get item from
@@ -4721,11 +4735,12 @@ def conv_shift_layer(a, b, name=None, layer_attr=None):
4721
4735
4722
4736
:param name: The name of this layer. It is optional.
4723
4737
:type name: basestring
4724
- :param a: Input layer a .
4738
+ :param a: The first input of this layer .
4725
4739
:type a: LayerOutput
4726
- :param b: input layer b .
4740
+ :param b: The second input of this layer .
4727
4741
:type b: LayerOutput
4728
- :param layer_attr: layer's extra attribute.
4742
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4743
+ details.
4729
4744
:type layer_attr: ExtraLayerAttribute
4730
4745
:return: LayerOutput object.
4731
4746
:rtype: LayerOutput
@@ -4756,8 +4771,8 @@ def tensor_layer(a,
4756
4771
bias_attr = None ,
4757
4772
layer_attr = None ):
4758
4773
"""
4759
- This layer performs tensor operation for two input .
4760
- For example, each sample :
4774
+ This layer performs tensor operation on two inputs .
4775
+ For example:
4761
4776
4762
4777
.. math::
4763
4778
y_{i} = a * W_{i} * {b^\mathrm{T}}, i=0,1,...,K-1
@@ -4777,21 +4792,23 @@ def tensor_layer(a,
4777
4792
4778
4793
:param name: The name of this layer. It is optional.
4779
4794
:type name: basestring
4780
- :param a: Input layer a .
4795
+ :param a: The first input of this layer .
4781
4796
:type a: LayerOutput
4782
- :param b: input layer b .
4797
+ :param b: The second input of this layer .
4783
4798
:type b: LayerOutput
4784
- :param size: the layer dimension.
4785
- :type size: int.
4799
+ :param size: The dimension of this layer .
4800
+ :type size: int
4786
4801
:param act: Activation type. LinearActivation is the default.
4787
4802
:type act: BaseActivation
4788
- :param param_attr: The Parameter Attribute.
4803
+ :param param_attr: The parameter attribute. See ParameterAttribute for
4804
+ details.
4789
4805
:type param_attr: ParameterAttribute
4790
4806
:param bias_attr: The bias attribute. If the parameter is set to False or an object
4791
4807
whose type is not ParameterAttribute, no bias is defined. If the
4792
4808
parameter is set to True, the bias is initialized to zero.
4793
4809
:type bias_attr: ParameterAttribute | None | bool | Any
4794
- :param layer_attr: Extra Layer config.
4810
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4811
+ details.
4795
4812
:type layer_attr: ExtraLayerAttribute | None
4796
4813
:return: LayerOutput object.
4797
4814
:rtype: LayerOutput
@@ -4827,7 +4844,7 @@ def selective_fc_layer(input,
4827
4844
layer_attr = None ):
4828
4845
"""
4829
4846
Selectived fully connected layer. Different from fc_layer, the output
4830
- of this layer maybe sparse. It requires an additional input to indicate
4847
+ of this layer can be sparse. It requires an additional input to indicate
4831
4848
several selected columns for output. If the selected columns is not
4832
4849
specified, selective_fc_layer acts exactly like fc_layer.
4833
4850
@@ -4841,21 +4858,33 @@ def selective_fc_layer(input,
4841
4858
:type name: basestring
4842
4859
:param input: The input of this layer.
4843
4860
:type input: LayerOutput | list | tuple
4844
- :param select: The select layer. The output of select layer should be a
4845
- sparse binary matrix, and treat as the mask of selective fc.
4846
- If is None, acts exactly like fc_layer.
4861
+ :param select: The layer to select columns to output. It should be a sparse
4862
+ binary matrix, and is treated as the mask of selective fc. If
4863
+ it is not set or set to None, selective_fc_layer acts exactly
4864
+ like fc_layer.
4847
4865
:type select: LayerOutput
4848
- :param size: The layer dimension.
4866
+ :param size: The dimension of this layer, which should be equal to that of
4867
+ the layer 'select'.
4849
4868
:type size: int
4850
4869
:param act: Activation type. TanhActivation is the default.
4851
4870
:type act: BaseActivation
4852
- :param param_attr: The Parameter Attribute.
4871
+ :param pass_generation: The flag which indicates whether it is during generation.
4872
+ :type pass_generation: bool
4873
+ :param has_selected_colums: The flag which indicates whether the parameter 'select'
4874
+ has been set. True is the default.
4875
+ :type has_selected_colums: bool
4876
+ :param mul_ratio: A ratio helps to judge how sparse the output is and determine
4877
+ the computation method for speed consideration.
4878
+ :type mul_ratio: float
4879
+ :param param_attr: The parameter attribute. See ParameterAttribute for
4880
+ details.
4853
4881
:type param_attr: ParameterAttribute
4854
4882
:param bias_attr: The bias attribute. If the parameter is set to False or an object
4855
4883
whose type is not ParameterAttribute, no bias is defined. If the
4856
4884
parameter is set to True, the bias is initialized to zero.
4857
4885
:type bias_attr: ParameterAttribute | None | bool | Any
4858
- :param layer_attr: Extra Layer config.
4886
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4887
+ details.
4859
4888
:type layer_attr: ExtraLayerAttribute | None
4860
4889
:return: LayerOutput object.
4861
4890
:rtype: LayerOutput
@@ -4906,7 +4935,7 @@ def selective_fc_layer(input,
4906
4935
@layer_support ()
4907
4936
def sampling_id_layer (input , name = None , layer_attr = None ):
4908
4937
"""
4909
- A layer for sampling id from multinomial distribution from the input layer.
4938
+ A layer for sampling id from a multinomial distribution from the input layer.
4910
4939
Sampling one id for one sample.
4911
4940
4912
4941
The simple usage is:
@@ -4919,8 +4948,9 @@ def sampling_id_layer(input, name=None, layer_attr=None):
4919
4948
:type input: LayerOutput
4920
4949
:param name: The name of this layer. It is optional.
4921
4950
:type name: basestring
4922
- :param layer_attr: Extra Layer config.
4923
- :type layer_attr: ExtraLayerAttribute | None
4951
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4952
+ details.
4953
+ :type layer_attr: ExtraLayerAttribute
4924
4954
:return: LayerOutput object.
4925
4955
:rtype: LayerOutput
4926
4956
"""
@@ -4941,8 +4971,7 @@ def slope_intercept_layer(input,
4941
4971
intercept = 0.0 ,
4942
4972
layer_attr = None ):
4943
4973
"""
4944
- This layer for applying a slope and an intercept to the input
4945
- element-wise. There is no activation and weight.
4974
+ This layer for applying a slope and an intercept to the input.
4946
4975
4947
4976
.. math::
4948
4977
y = slope * x + intercept
@@ -4957,12 +4986,13 @@ def slope_intercept_layer(input,
4957
4986
:type input: LayerOutput
4958
4987
:param name: The name of this layer. It is optional.
4959
4988
:type name: basestring
4960
- :param slope: the scale factor.
4961
- :type slope: float.
4962
- :param intercept: the offset.
4963
- :type intercept: float.
4964
- :param layer_attr: Extra Layer config.
4965
- :type layer_attr: ExtraLayerAttribute | None
4989
+ :param slope: The scale factor.
4990
+ :type slope: float
4991
+ :param intercept: The offset.
4992
+ :type intercept: float
4993
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
4994
+ details.
4995
+ :type layer_attr: ExtraLayerAttribute
4966
4996
:return: LayerOutput object.
4967
4997
:rtype: LayerOutput
4968
4998
"""
@@ -5017,12 +5047,13 @@ def linear_comb_layer(weights, vectors, size=None, name=None, layer_attr=None):
5017
5047
:type weights: LayerOutput
5018
5048
:param vectors: The vector layer.
5019
5049
:type vectors: LayerOutput
5020
- :param size: the dimension of this layer.
5050
+ :param size: The dimension of this layer.
5021
5051
:type size: int
5022
5052
:param name: The name of this layer. It is optional.
5023
5053
:type name: basestring
5024
- :param layer_attr: Extra Layer config.
5025
- :type layer_attr: ExtraLayerAttribute | None
5054
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
5055
+ details.
5056
+ :type layer_attr: ExtraLayerAttribute
5026
5057
:return: LayerOutput object.
5027
5058
:rtype: LayerOutput
5028
5059
"""
@@ -5069,11 +5100,11 @@ def block_expand_layer(input,
5069
5100
5070
5101
outputW = 1 + (2 * padding_x + imgSizeW - block_x + stride_x - 1) / stride_x
5071
5102
5072
- The expand method is the same with ExpandConvLayer, but saved the transposed
5103
+ The expanding method is the same with ExpandConvLayer, but saved the transposed
5073
5104
value. After expanding, output.sequenceStartPositions will store timeline.
5074
- The number of time steps are outputH * outputW and the dimension of each
5105
+ The number of time steps is outputH * outputW and the dimension of each
5075
5106
time step is block_y * block_x * num_channels. This layer can be used after
5076
- convolution neural network, and before recurrent neural network.
5107
+ convolutional neural network, and before recurrent neural network.
5077
5108
5078
5109
The simple usage is:
5079
5110
@@ -5088,8 +5119,10 @@ def block_expand_layer(input,
5088
5119
5089
5120
:param input: The input of this layer.
5090
5121
:type input: LayerOutput
5091
- :param num_channels: The channel number of input layer.
5092
- :type num_channels: int | None
5122
+ :param num_channels: The number of input channels. If the parameter is not set or
5123
+ set to None, its actual value will be automatically set to
5124
+ the channels number of the input.
5125
+ :type num_channels: int
5093
5126
:param block_x: The width of sub block.
5094
5127
:type block_x: int
5095
5128
:param block_y: The width of sub block.
@@ -5103,9 +5136,10 @@ def block_expand_layer(input,
5103
5136
:param padding_y: The padding size in vertical direction.
5104
5137
:type padding_y: int
5105
5138
:param name: The name of this layer. It is optional.
5106
- :type name: None | basestring.
5107
- :param layer_attr: Extra Layer config.
5108
- :type layer_attr: ExtraLayerAttribute | None
5139
+ :type name: basestring.
5140
+ :param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
5141
+ details.
5142
+ :type layer_attr: ExtraLayerAttribute
5109
5143
:return: LayerOutput object.
5110
5144
:rtype: LayerOutput
5111
5145
"""
0 commit comments