Skip to content

Commit 9e55291

Browse files
zhangting2020Aurelius84
authored andcommitted
[cherry-pick] fix bias_attr's bug of conv and conv_transpose, test=release/1.6 (#20704) (#20716)
1 parent c2f86f9 commit 9e55291

File tree

1 file changed

+16
-4
lines changed
  • python/paddle/fluid/layers

1 file changed

+16
-4
lines changed

python/paddle/fluid/layers/nn.py

100644100755
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,10 @@ def _get_default_param_initializer():
28012801
"data_format": data_format,
28022802
})
28032803

2804-
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
2804+
if data_format == 'NCHW':
2805+
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
2806+
else:
2807+
pre_act = helper.append_bias_op(pre_bias, dim_start=3, dim_end=4)
28052808

28062809
return helper.append_activation(pre_act)
28072810

@@ -3049,7 +3052,10 @@ def _get_default_param_initializer():
30493052
"data_format": data_format,
30503053
})
30513054

3052-
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
3055+
if data_format == 'NCDHW':
3056+
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
3057+
else:
3058+
pre_act = helper.append_bias_op(pre_bias, dim_start=4, dim_end=5)
30533059

30543060
return helper.append_activation(pre_act)
30553061

@@ -5148,7 +5154,10 @@ def is_list_or_tuple(ele):
51485154
'data_format': data_format
51495155
})
51505156

5151-
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
5157+
if data_format == 'NCHW':
5158+
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
5159+
else:
5160+
pre_act = helper.append_bias_op(pre_bias, dim_start=3, dim_end=4)
51525161
out = helper.append_activation(pre_act)
51535162
return out
51545163

@@ -5423,7 +5432,10 @@ def is_list_or_tuple(ele):
54235432
'data_format': data_format
54245433
})
54255434

5426-
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
5435+
if data_format == 'NCHW':
5436+
pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
5437+
else:
5438+
pre_act = helper.append_bias_op(pre_bias, dim_start=4, dim_end=5)
54275439
out = helper.append_activation(pre_act)
54285440
return out
54295441

0 commit comments

Comments
 (0)