diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py old mode 100644 new mode 100755 index fd9af1a015bbda0bb90d5ad0b43bc8707debe251..dd657d2c1d89472d4448bedcd9e3a561513778ff --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -2801,7 +2801,10 @@ def conv2d(input, "data_format": data_format, }) - pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + if data_format == 'NCHW': + pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + else: + pre_act = helper.append_bias_op(pre_bias, dim_start=3, dim_end=4) return helper.append_activation(pre_act) @@ -3049,7 +3052,10 @@ def conv3d(input, "data_format": data_format, }) - pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + if data_format == 'NCDHW': + pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + else: + pre_act = helper.append_bias_op(pre_bias, dim_start=4, dim_end=5) return helper.append_activation(pre_act) @@ -5148,7 +5154,10 @@ def conv2d_transpose(input, 'data_format': data_format }) - pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + if data_format == 'NCHW': + pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + else: + pre_act = helper.append_bias_op(pre_bias, dim_start=3, dim_end=4) out = helper.append_activation(pre_act) return out @@ -5423,7 +5432,10 @@ def conv3d_transpose(input, 'data_format': data_format }) - pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + if data_format == 'NCHW': + pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2) + else: + pre_act = helper.append_bias_op(pre_bias, dim_start=4, dim_end=5) out = helper.append_activation(pre_act) return out