Skip to content

Commit 7a55704

Browse files
author
Yibing Liu
committed
Expose param group in conv2d_transpose api
1 parent 6e13c86 commit 7a55704

File tree

1 file changed

+9
-1
lines changed
  • python/paddle/fluid/layers

1 file changed

+9
-1
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,7 @@ def conv2d_transpose(input,
17061706
padding=0,
17071707
stride=1,
17081708
dilation=1,
1709+
groups=None,
17091710
param_attr=None,
17101711
bias_attr=None,
17111712
use_cudnn=True,
@@ -1776,6 +1777,12 @@ def conv2d_transpose(input,
17761777
dilation(int|tuple): The dilation size. If dilation is a tuple, it must
17771778
contain two integers, (dilation_H, dilation_W). Otherwise, the
17781779
dilation_H = dilation_W = dilation. Default: dilation = 1.
1780+
groups(int): The groups number of the Conv2d transpose layer. Inspired by
1781+
grouped convolution in Alex Krizhevsky's Deep CNN paper, in which
1782+
when group=2, the first half of the filters is only connected to the
1783+
first half of the input channels, while the second half of the
1784+
filters is only connected to the second half of the input channels.
1785+
Default: groups=1
17791786
param_attr(ParamAttr): The parameters to the Conv2d_transpose Layer.
17801787
Default: None
17811788
bias_attr(ParamAttr): Bias parameter for the Conv2d layer. Default: None
@@ -1830,7 +1837,8 @@ def conv2d_transpose(input,
18301837
filter_size = utils.convert_to_list(filter_size, 2,
18311838
'conv2d_transpose.filter_size')
18321839

1833-
filter_shape = [input_channel, num_filters] + filter_size
1840+
groups = 1 if groups is None else groups
1841+
filter_shape = [input_channel, num_filters / groups] + filter_size
18341842
img_filter = helper.create_parameter(
18351843
dtype=input.dtype, shape=filter_shape, attr=helper.param_attr)
18361844

0 commit comments

Comments
 (0)