Skip to content

Commit e135894

Browse files
committed
Refine AvgPooling with excludeMode to make it compatible with the raw prototxt
1 parent 6b18b3c commit e135894

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

proto/ModelConfig.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ message PoolConfig {
140140
optional uint32 img_size_z = 17 [ default = 1 ];
141141
optional uint32 padding_z = 18 [ default = 1 ];
142142

143-
optional bool exclude_mode = 19 [ default = true ];
143+
optional bool exclude_mode = 19;
144144
}
145145

146146
message SppConfig {

python/paddle/trainer/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ def parse_pool(pool, input_layer_name, pool_conf, ceil_mode, exclude_mode):
12621262
pool_conf.output_y = cnn_output_size(pool_conf.img_size_y, pool_conf.size_y,
12631263
pool_conf.padding_y,
12641264
pool_conf.stride_y, not ceil_mode)
1265-
1266-
pool_conf.exclude_mode = exclude_mode
1265+
if exclude_mode != None:
1266+
pool_conf.exclude_mode = exclude_mode
12671267

12681268

12691269
def parse_pool3d(pool, input_layer_name, pool_conf, ceil_mode):
@@ -2305,7 +2305,7 @@ def __init__(self, name, inputs, **xargs):
23052305
class PoolLayer(LayerBase):
23062306
layer_type = 'pool'
23072307

2308-
def __init__(self, name, inputs, ceil_mode=True, exclude_mode=True,
2308+
def __init__(self, name, inputs, ceil_mode=True, exclude_mode=None,
23092309
**xargs):
23102310
use_mkldnn = int(g_command_config_args.get("use_mkldnn", 0))
23112311
if self.layer_type == "mkldnn_pool":

python/paddle/trainer_config_helpers/layers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ def img_pool_layer(input,
27102710
stride_y=None,
27112711
padding_y=None,
27122712
ceil_mode=True,
2713-
exclude_mode=True):
2713+
exclude_mode=None):
27142714
"""
27152715
Image pooling Layer.
27162716
@@ -2779,8 +2779,9 @@ def img_pool_layer(input,
27792779
be used.
27802780
:type ceil_mode: bool
27812781
:param exclude_mode: Whether to exclude the padding cells when calculating, but only
2782-
work when pool_type is AvgPooling. If use cudnn, use CudnnAvgPooling
2783-
or CudnnAvgInclPadPooling as pool_type to identify.
2782+
work when pool_type is AvgPooling. If None, also exclude the padding
2783+
cells. If use cudnn, use CudnnAvgPooling or CudnnAvgInclPadPooling
2784+
as pool_type to identify the mode.
27842785
:type exclude_mode: bool
27852786
:return: LayerOutput object.
27862787
:rtype: LayerOutput

0 commit comments

Comments
 (0)