Pooling operator expects kernel size even when 'global_pool' is set to True
Pooling operator expects kernel size even when 'global_pool' is set to True. If 'global_pool' is true, kernel should automatically be set to (height, width). User shouldn't have to provide kernel size.
Environment info
Operating System: Ubuntu
Compiler: gcc
Package used (Python/R/Scala/Julia): Python
MXNet version: 0.10
Or if installed from source:
MXNet commit hash (git rev-parse HEAD):
If you are using python package, please provide
Python version and distribution: Python 2.7.12
If you are using R package, please provide
R sessionInfo():
Error Message:
Traceback (most recent call last):
File "resnet50.py", line 965, in <module>
name='pool5')
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.0-py2.7.egg/mxnet/_ctypes/symbol.py", line 181, in creator
ctypes.byref(sym_handle)))
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.0-py2.7.egg/mxnet/base.py", line 84, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: Required parameter kernel of Shape(tuple) is not presented, in operator Pooling(name="", global_pool="True", pool_type="avg")
Minimum reproducible example
pool5 = mx.symbol.Pooling(data=data,
pool_type='avg',
global_pool=True,
#kernel=(1,1),
name='pool')
Steps to reproduce
or if you are running standard examples, please provide the commands you have run that lead to the error.
- Create a pooling layer with 'global_pool' set to True and kernel size not set (like shown above)
- Run the code.
'kernel=(1,1)' is a good setting and It's convenient for FCN. Please refer to https://stackoverflow.com/questions/42070528/what-does-global-pooling-do
The kernel parameter is required to determine whether the Pooling Operation is 1d or 2d or 3d based on the shape of the kernel. This is also used to determine the shape of stride. The size of each dimension in kernel doesn't matter when the global_pool is set to True. https://github.com/apache/incubator-mxnet/blob/master/src/operator/pooling-inl.h#L104 https://github.com/apache/incubator-mxnet/blob/master/src/operator/pooling-inl.h#L107
Since the documentation was not clear to indhub@, is there an opportunity here to clarify/improve the API documentation? What is we update the document to say: from: global_pool (boolean, optional, default=False) – Ignore kernel size, do global pooling based on current input feature map. to: (something like this) global_pool (boolean, optional, default=False) – Ignore kernel size, but the kernel must be specified to determine the shape of the stride and whether the Pooling Operation is 1d or 2d or 3d based on the shape of the kernel. Do global pooling based on current input feature map.
@indhub this does not seem necessary anymore. Please close:
pool5 = mx.symbol.Pooling(data=mx.sym.var('data'),
pool_type='avg',
global_pool=True,
name='pool')
mx.test_utils.simple_forward(pool5, data=np.ones((1,3,224,224)))
array([[[[ 1.]],
[[ 1.]],
[[ 1.]]]], dtype=float32)