Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max pool Layer with mask #4891

Merged
merged 19 commits into from
Nov 14, 2017
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
720274d
add max-pool-with-mask python interface
NHZlX Oct 18, 2017
9621213
add max-pool-with-mask c++ impl
NHZlX Oct 18, 2017
afa6902
add cuda and cpu pool_forward_with_mask impl
NHZlX Oct 18, 2017
ff20a11
add layerGrad test and maskoutput test
NHZlX Oct 18, 2017
c876dfa
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Oct 18, 2017
8106f41
add the max pool with mask layer
NHZlX Nov 10, 2017
a54565e
delete mask pool interface from poolprojection
NHZlX Nov 10, 2017
ba2e5de
pull develop and fix conflict
NHZlX Nov 10, 2017
2ef1867
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 10, 2017
921f723
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 10, 2017
3428a52
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 10, 2017
9e894f6
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 11, 2017
4ebb05c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 11, 2017
b29cbd4
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 11, 2017
69147da
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 13, 2017
471573e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 13, 2017
5aa3e76
fix bug with default parameter
NHZlX Nov 13, 2017
0b9c4cd
fix comments
NHZlX Nov 14, 2017
e19b931
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
NHZlX Nov 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/paddle/trainer/config_parser.py
Original file line number Diff line number Diff line change
@@ -1250,9 +1250,9 @@ def parse_bilinear(bilinear, input_layer_name, bilinear_conf):
def parse_pool(pool, input_layer_name, pool_conf, ceil_mode):
pool_conf.pool_type = pool.pool_type
config_assert(pool.pool_type in [
'max-projection', 'avg-projection', 'cudnn-max-pool', 'cudnn-avg-pool'
], "pool-type %s is not in "
"['max-projection', 'avg-projection', "
'max-projection', 'avg-projection', 'max-pool-with-mask', 'cudnn-max-pool', 'cudnn-avg-pool'
], "pool-type %s is not in " \
"['max-projection', 'avg-projection', 'max-pool-with-mask'," \
"'cudnn-max-pool', 'cudnn-avg-pool']" % pool.pool_type)

pool_conf.channels = pool.channels
6 changes: 3 additions & 3 deletions python/paddle/trainer_config_helpers/layers.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
from .activations import LinearActivation, SigmoidActivation, TanhActivation, \
ReluActivation, IdentityActivation, SoftmaxActivation, BaseActivation
from .evaluators import *
from .poolings import MaxPooling, AvgPooling, BasePoolingType, \
from .poolings import MaxPooling, AvgPooling, MaxWithMaskPooling, BasePoolingType, \
CudnnAvgPooling, CudnnMaxPooling
from .attrs import *
from .default_decorators import *
@@ -2652,9 +2652,9 @@ def img_pool_layer(input,
elif isinstance(pool_type, AvgPooling):
pool_type.name = 'avg'

assert type(pool_type) in [AvgPooling, MaxPooling, CudnnAvgPooling,
assert type(pool_type) in [AvgPooling, MaxPooling, MaxWithMaskPooling, CudnnAvgPooling,
CudnnMaxPooling], \
"only (Cudnn)AvgPooling, (Cudnn)MaxPooling are supported"
"only (Cudnn)AvgPooling, (Cudnn)MaxPooling MaxWithMaskPooling are supported"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add , before MaxWithMaskPooling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


type_name = pool_type.name + '-projection' \
if (
17 changes: 15 additions & 2 deletions python/paddle/trainer_config_helpers/poolings.py
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@
"""

__all__ = [
"BasePoolingType", "MaxPooling", "AvgPooling", "CudnnMaxPooling",
"CudnnAvgPooling", "SumPooling", "SquareRootNPooling"
"BasePoolingType", "MaxPooling", "AvgPooling", "MaxWithMaskPooling",
"CudnnMaxPooling", "CudnnAvgPooling", "SumPooling", "SquareRootNPooling"
]


@@ -55,6 +55,19 @@ def __init__(self, output_max_index=None):
self.output_max_index = output_max_index


class MaxWithMaskPooling(BasePoolingType):
"""
MaxWithMask pooling.

Not only return the very large values for each dimension in sequence or time steps,
but also the location indices of found maxinum values.

"""

def __init__(self):
BasePoolingType.__init__(self, "max-pool-with-mask")


class CudnnMaxPooling(BasePoolingType):
"""
Cudnn max pooling only support GPU. Return the maxinum value in the