提交 b14a0e30 authored 作者: Li's avatar Li

better wording

上级 bd5dc5a8
...@@ -39,6 +39,10 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0)): ...@@ -39,6 +39,10 @@ def max_pool_2d(input, ds, ignore_border=False, st=None, padding=(0, 0)):
over rows/cols to get the the next pool region. over rows/cols to get the the next pool region.
if st is None, it is considered equal to ds if st is None, it is considered equal to ds
(no overlap on pooling regions) (no overlap on pooling regions)
:param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints
""" """
if input.ndim < 2: if input.ndim < 2:
...@@ -101,8 +105,9 @@ class DownsampleFactorMax(Op): ...@@ -101,8 +105,9 @@ class DownsampleFactorMax(Op):
extra row/col of partial downsampling (False) or ignore it (True). extra row/col of partial downsampling (False) or ignore it (True).
:type ignore_border: bool :type ignore_border: bool
:param padding: (pad_h, pad_w), pad zeros on four borders :param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h for padding rows, and pad_w for columns. of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints :type padding: tuple of two ints
:rtype: list :rtype: list
...@@ -172,8 +177,9 @@ class DownsampleFactorMax(Op): ...@@ -172,8 +177,9 @@ class DownsampleFactorMax(Op):
(no overlap on pooling regions) (no overlap on pooling regions)
: type st: list or tuple of two ints : type st: list or tuple of two ints
:param padding: (pad_h, pad_w), pad zeros on four borders :param padding: (pad_h, pad_w), pad zeros to extend beyond four borders
of the images, pad_h for padding rows, and pad_w for columns. of the images, pad_h is the size of the top and bottom margins,
and pad_w is the size of the left and right margins.
:type padding: tuple of two ints :type padding: tuple of two ints
""" """
...@@ -226,10 +232,11 @@ class DownsampleFactorMax(Op): ...@@ -226,10 +232,11 @@ class DownsampleFactorMax(Op):
pc = zz.shape[-1] pc = zz.shape[-1]
ds0, ds1 = self.ds ds0, ds1 = self.ds
st0, st1 = self.st st0, st1 = self.st
img_rows = x.shape[-2] + 2 * self.padding[0]
img_cols = x.shape[-1] + 2 * self.padding[1]
pad_h = self.padding[0] pad_h = self.padding[0]
pad_w = self.padding[1] pad_w = self.padding[1]
img_rows = x.shape[-2] + 2 * pad_h
img_cols = x.shape[-1] + 2 * pad_w
# pad the image # pad the image
fill = x.min()-1. fill = x.min()-1.
...@@ -377,10 +384,11 @@ class DownsampleFactorMaxGrad(Op): ...@@ -377,10 +384,11 @@ class DownsampleFactorMaxGrad(Op):
pc = maxout.shape[-1] pc = maxout.shape[-1]
ds0, ds1 = self.ds ds0, ds1 = self.ds
st0, st1 = self.st st0, st1 = self.st
img_rows = x.shape[-2] + 2 * self.padding[0]
img_cols = x.shape[-1] + 2 * self.padding[1]
pad_h = self.padding[0] pad_h = self.padding[0]
pad_w = self.padding[1] pad_w = self.padding[1]
img_rows = x.shape[-2] + 2 * pad_h
img_cols = x.shape[-1] + 2 * pad_w
# pad the image # pad the image
fill = x.min()-1 fill = x.min()-1
y = numpy.zeros( y = numpy.zeros(
......
...@@ -267,10 +267,16 @@ class TestDownsampleFactorMax(utt.InferShapeTester): ...@@ -267,10 +267,16 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
def test_DownsampleFactorMaxPaddingStride_grad(self): def test_DownsampleFactorMaxPaddingStride_grad(self):
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
imval = rng.rand(1, 1, 10, 10) * 10.0 imgsizes = ((10, 10), (10, 5))
maxpoolsize = (5, 3) maxpoolsizes = ((5, 3),(3, 5))
stridesize = (3, 2) stridesizes = ((3, 2), (2, 3))
paddingsize = (2, 2) paddingsizes = ((2, 2),(2, 1))
for i in range(len(imgsizes)):
imgsize = imgsizes[i]
imval = rng.rand(1, 1, imgsize[0], imgsize[1]) * 10.0
maxpoolsize = maxpoolsizes[i]
stridesize = stridesizes[i]
paddingsize = paddingsizes[i]
def mp(input): def mp(input):
return DownsampleFactorMax( return DownsampleFactorMax(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论