Skip to content

Commit 9e8fba4

Browse files
author
chengduozh
committed
fix conv doc
test=develop
1 parent 3cb8da9 commit 9e8fba4

File tree

2 files changed

+56
-33
lines changed

2 files changed

+56
-33
lines changed

paddle/fluid/API.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ paddle.fluid.layers.sequence_conv ArgSpec(args=['input', 'num_filters', 'filter_
6565
paddle.fluid.layers.conv2d ArgSpec(args=['input', 'num_filters', 'filter_size', 'stride', 'padding', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None, None, None, True, None, None))
6666
paddle.fluid.layers.conv3d ArgSpec(args=['input', 'num_filters', 'filter_size', 'stride', 'padding', 'dilation', 'groups', 'param_attr', 'bias_attr', 'use_cudnn', 'act', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None, None, None, True, None, None))
6767
paddle.fluid.layers.sequence_pool ArgSpec(args=['input', 'pool_type'], varargs=None, keywords=None, defaults=None)
68-
paddle.fluid.layers.sequence_softmax ArgSpec(args=['input', 'param_attr', 'bias_attr', 'use_cudnn'], varargs=None, keywords=None, defaults=(None, None, False))
69-
paddle.fluid.layers.softmax ArgSpec(args=['input', 'param_attr', 'bias_attr', 'use_cudnn', 'name'], varargs=None, keywords=None, defaults=(None, None, True, None))
68+
paddle.fluid.layers.sequence_softmax ArgSpec(args=['input', 'use_cudnn'], varargs=None, keywords=None, defaults=(False))
69+
paddle.fluid.layers.softmax ArgSpec(args=['input', use_cudnn', 'name'], varargs=None, keywords=None, defaults=(True, None))
7070
paddle.fluid.layers.pool2d ArgSpec(args=['input', 'pool_size', 'pool_type', 'pool_stride', 'pool_padding', 'global_pooling', 'use_cudnn', 'ceil_mode', 'name'], varargs=None, keywords=None, defaults=(-1, 'max', 1, 0, False, True, False, None))
7171
paddle.fluid.layers.pool3d ArgSpec(args=['input', 'pool_size', 'pool_type', 'pool_stride', 'pool_padding', 'global_pooling', 'use_cudnn', 'ceil_mode', 'name'], varargs=None, keywords=None, defaults=(-1, 'max', 1, 0, False, True, False, None))
7272
paddle.fluid.layers.batch_norm ArgSpec(args=['input', 'act', 'is_test', 'momentum', 'epsilon', 'param_attr', 'bias_attr', 'data_layout', 'in_place', 'name', 'moving_mean_name', 'moving_variance_name', 'do_model_average_for_mean_and_var', 'fuse_with_relu'], varargs=None, keywords=None, defaults=(None, False, 0.9, 1e-05, None, None, 'NCHW', False, None, None, None, False, False))

python/paddle/fluid/layers/nn.py

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def dynamic_lstm(input,
389389
390390
hidden_dim = 512
391391
forward_proj = fluid.layers.fc(input=input_seq, size=hidden_dim * 4,
392-
act=None, bias_attr=None)
392+
bias_attr=False)
393393
forward, _ = fluid.layers.dynamic_lstm(
394394
input=forward_proj, size=hidden_dim * 4, use_peepholes=False)
395395
"""
@@ -1277,7 +1277,9 @@ def sequence_conv(input,
12771277
filter_size (int): the filter size (H and W).
12781278
filter_stride (int): stride of the filter.
12791279
padding (bool): if True, add paddings.
1280-
bias_attr (ParamAttr|None): attributes for bias
1280+
bias_attr (ParamAttr): The parameter attribute for the bias of this layer.
1281+
If it is set to False, no bias will be added to the output units.
1282+
If it is set to None, the bias is initialized zero. Default: None.
12811283
param_attr (ParamAttr|None): attributes for parameter
12821284
act (str): the activation type
12831285
@@ -1308,7 +1310,7 @@ def sequence_conv(input,
13081310
return helper.append_activation(pre_act)
13091311

13101312

1311-
def sequence_softmax(input, param_attr=None, bias_attr=None, use_cudnn=False):
1313+
def sequence_softmax(input, use_cudnn=False):
13121314
"""
13131315
This function computes the softmax activation among all time-steps for each
13141316
sequence. The dimension of each time-step should be 1. Thus, the shape of
@@ -1328,8 +1330,6 @@ def sequence_softmax(input, param_attr=None, bias_attr=None, use_cudnn=False):
13281330
13291331
Args:
13301332
input (Variable): The input variable which is a LoDTensor.
1331-
bias_attr (ParamAttr|None): attributes for bias
1332-
param_attr (ParamAttr|None): attributes for parameter
13331333
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn \
13341334
library is installed. Default: False
13351335
@@ -1355,7 +1355,7 @@ def sequence_softmax(input, param_attr=None, bias_attr=None, use_cudnn=False):
13551355
return softmax_out
13561356

13571357

1358-
def softmax(input, param_attr=None, bias_attr=None, use_cudnn=True, name=None):
1358+
def softmax(input, use_cudnn=True, name=None):
13591359
"""
13601360
The input of the softmax operator is a tensor of any rank. The output tensor
13611361
has the same shape as the input.
@@ -1382,8 +1382,6 @@ def softmax(input, param_attr=None, bias_attr=None, use_cudnn=True, name=None):
13821382
13831383
Args:
13841384
input (Variable): The input variable.
1385-
bias_attr (ParamAttr): attributes for bias
1386-
param_attr (ParamAttr): attributes for parameter
13871385
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn \
13881386
library is installed.
13891387
@@ -1492,13 +1490,19 @@ def conv2d(input,
14921490
the first half of the filters is only connected to the first half
14931491
of the input channels, while the second half of the filters is only
14941492
connected to the second half of the input channels. Default: groups=1
1495-
param_attr (ParamAttr): The parameters to the Conv2d Layer. Default: None
1496-
bias_attr (ParamAttr): Bias parameter for the Conv2d layer. Default: None
1493+
param_attr (ParamAttr): The parameter attribute for learnable parameters/weights
1494+
of this layer. If it is set to None, the parameter is initialized with
1495+
:math:`Normal(0.0, std)`, and the :math:`std` is :math:`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`.
1496+
Default: None.
1497+
bias_attr (ParamAttr): The parameter attribute for the bias of this layer.
1498+
If it is set to False, no bias will be added to the output units.
1499+
If it is set to None, the bias is initialized zero. Default: None.
14971500
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn
14981501
library is installed. Default: True
1499-
act (str): Activation type. Default: None
1502+
act (str): Activation type, if it is set to None, activation is not appended.
1503+
Default: None
15001504
name (str|None): A name for this layer(optional). If set None, the layer
1501-
will be named automatically.
1505+
will be named automatically. Default: None
15021506
15031507
Returns:
15041508
Variable: The tensor variable storing the convolution and \
@@ -1516,7 +1520,7 @@ def conv2d(input,
15161520
"""
15171521

15181522
num_channels = input.shape[1]
1519-
1523+
assert param_attr is not False, "param_attr should not be False here."
15201524
l_type = 'conv2d'
15211525
if (num_channels == groups and num_filters % num_channels == 0 and
15221526
not use_cudnn):
@@ -1544,7 +1548,8 @@ def conv2d(input,
15441548
filter_shape = [num_filters, int(num_filter_channels)] + filter_size
15451549

15461550
def _get_default_param_initializer():
1547-
std = (2.0 / (filter_size[0]**2 * num_channels))**0.5
1551+
filter_num_elem = filter_size[0] * filter_size[1] * num_channels
1552+
std = (2.0 / (filter_num_elem))**0.5
15481553
return Normal(0.0, std, 0)
15491554

15501555
filter_param = helper.create_parameter(
@@ -1655,13 +1660,19 @@ def conv3d(input,
16551660
the first half of the filters is only connected to the first half
16561661
of the input channels, while the second half of the filters is only
16571662
connected to the second half of the input channels. Default: groups=1
1658-
param_attr (ParamAttr): The parameters to the Conv3d Layer. Default: None
1659-
bias_attr (ParamAttr): Bias parameter for the Conv3d layer. Default: None
1663+
param_attr (ParamAttr): The parameter attribute for learnable parameters/weights
1664+
of this layer. If it is set to None, the parameter is initialized with
1665+
:math:`Normal(0.0, std)`, and the :math:`std` is :math:`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`.
1666+
Default: None.
1667+
bias_attr (ParamAttr): The parameter attribute for the bias of this layer.
1668+
If it is set to False, no bias will be added to the output units.
1669+
If it is set to None, the bias is initialized zero. Default: None.
16601670
use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn
16611671
library is installed. Default: True
1662-
act (str): Activation type. Default: None
1672+
act (str): Activation type, if it is set to None, activation is not appended.
1673+
Default: None.
16631674
name (str|None): A name for this layer(optional). If set None, the layer
1664-
will be named automatically.
1675+
will be named automatically. Default: None.
16651676
16661677
Returns:
16671678
Variable: The tensor variable storing the convolution and \
@@ -1679,7 +1690,7 @@ def conv3d(input,
16791690
"""
16801691

16811692
l_type = 'conv3d'
1682-
1693+
assert param_attr is not False, "param_attr should not be False here."
16831694
helper = LayerHelper(l_type, **locals())
16841695
dtype = helper.input_dtype()
16851696

@@ -1704,7 +1715,9 @@ def conv3d(input,
17041715
filter_shape = [num_filters, num_filter_channels] + filter_size
17051716

17061717
def _get_default_param_initializer():
1707-
std = (2.0 / (filter_size[0]**3 * num_channels))**0.5
1718+
filter_elem_num = filter_size[0] * filter_size[1] * filter_size[
1719+
2] * num_channels
1720+
std = (2.0 / filter_elem_num)**0.5
17081721
return Normal(0.0, std, 0)
17091722

17101723
filter_param = helper.create_parameter(
@@ -2396,15 +2409,19 @@ def conv2d_transpose(input,
23962409
when group=2, the first half of the filters is only connected to the
23972410
first half of the input channels, while the second half of the
23982411
filters is only connected to the second half of the input channels.
2399-
Default: groups=1
2400-
param_attr(ParamAttr): The parameters to the Conv2d_transpose Layer.
2401-
Default: None
2402-
bias_attr(ParamAttr): Bias parameter for the Conv2d layer. Default: None
2412+
Default: groups = 1.
2413+
param_attr (ParamAttr): The parameter attribute for learnable parameters/weights
2414+
of this layer. If it is set to None, the parameter is initialized with
2415+
Xavier. Default: None.
2416+
bias_attr (ParamAttr): The parameter attribute for the bias of this layer.
2417+
If it is set to False, no bias will be added to the output units.
2418+
If it is set to None, the bias is initialized zero. Default: None.
24032419
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
2404-
library is installed. Default: True
2405-
act(str): Activation type. Default: None
2420+
library is installed. Default: True.
2421+
act (str): Activation type, if it is set to None, activation is not appended.
2422+
Default: None.
24062423
name(str|None): A name for this layer(optional). If set None, the layer
2407-
will be named automatically.
2424+
will be named automatically. Default: True.
24082425
24092426
Returns:
24102427
Variable: The tensor variable storing the convolution transpose result.
@@ -2455,6 +2472,7 @@ def conv2d_transpose(input,
24552472
else:
24562473
filter_size = utils.convert_to_list(filter_size, 2,
24572474
'conv2d_transpose.filter_size')
2475+
24582476
if output_size is None:
24592477
output_size = []
24602478
elif isinstance(output_size, list) or isinstance(output_size, int):
@@ -2464,6 +2482,7 @@ def conv2d_transpose(input,
24642482
padding = utils.convert_to_list(padding, 2, 'padding')
24652483
groups = 1 if groups is None else groups
24662484
filter_shape = [input_channel, num_filters // groups] + filter_size
2485+
24672486
img_filter = helper.create_parameter(
24682487
dtype=input.dtype, shape=filter_shape, attr=helper.param_attr)
24692488

@@ -2576,12 +2595,16 @@ def conv3d_transpose(input,
25762595
first half of the input channels, while the second half of the
25772596
filters is only connected to the second half of the input channels.
25782597
Default: groups=1
2579-
param_attr(ParamAttr): The parameters to the Conv3d_transpose Layer.
2580-
Default: None
2581-
bias_attr(ParamAttr): Bias parameter for the Conv3d layer. Default: None
2598+
param_attr (ParamAttr): The parameter attribute for learnable parameters/weights
2599+
of this layer. If it is set to None, the parameter is initialized with
2600+
Xavier. Default: None.
2601+
bias_attr (ParamAttr): The parameter attribute for the bias of this layer.
2602+
If it is set to False, no bias will be added to the output units.
2603+
If it is set to None, the bias is initialized zero. Default: None.
25822604
use_cudnn(bool): Use cudnn kernel or not, it is valid only when the cudnn
25832605
library is installed. Default: True
2584-
act(str): Activation type. Default: None
2606+
act (str): Activation type, if it is set to None, activation is not appended.
2607+
Default: None.
25852608
name(str|None): A name for this layer(optional). If set None, the layer
25862609
will be named automatically.
25872610

0 commit comments

Comments
 (0)