提交 f9e65e0e authored 作者: abergeron's avatar abergeron

Merge pull request #3337 from nouiz/ignore_border

Warn about pending ignore_border default value change.
......@@ -9,6 +9,7 @@ from __future__ import print_function
# This file should move along with conv.py
from six.moves import xrange
import six.moves.builtins as builtins
import warnings
import numpy
......@@ -44,7 +45,7 @@ def max_pool_2d_same_size(input, patch_size):
return outs
def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
def max_pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0),
mode='max'):
"""
Takes as input a N-D tensor, where N >= 2. It downscales the input image by
......@@ -58,7 +59,7 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
ds : tuple of length 2
Factor by which to downscale (vertical ds, horizontal ds).
(2,2) will halve the image in each dimension.
ignore_border : bool
ignore_border : bool (default None, will print a warning and set to False)
When True, (5,5) input with ds=(2,2) will generate a (2,2) output.
(3,3) otherwise.
st : tuple of lenght 2
......@@ -77,6 +78,15 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0),
"""
if input.ndim < 2:
raise NotImplementedError('max_pool_2d requires a dimension >= 2')
if ignore_border is None:
warnings.warn("max_pool_2d() will have the parameter ignore_border"
" default value changed to True (currently"
" False). To have consistent behavior with all Theano"
" version, explicitly add the parameter"
" ignore_border=True. (this is also faster than"
" ignore_border=False)",
stacklevel=2)
ignore_border = False
if input.ndim == 4:
op = DownsampleFactorMax(ds, ignore_border, st=st, padding=padding,
mode=mode)
......
......@@ -629,7 +629,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
x_vec = tensor.vector('x')
z = tensor.dot(x_vec.dimshuffle(0, 'x'),
x_vec.dimshuffle('x', 0))
y = max_pool_2d(input=z, ds=(2, 2))
y = max_pool_2d(input=z, ds=(2, 2), ignore_border=True)
C = tensor.exp(tensor.sum(y))
grad_hess = tensor.hessian(cost=C, wrt=x_vec)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论