提交 b3316526 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix doc formatting in pool.py.

上级 a85be0ab
...@@ -30,6 +30,7 @@ def max_pool_2d_same_size(input, patch_size): ...@@ -30,6 +30,7 @@ def max_pool_2d_same_size(input, patch_size):
of non-overlapping patches of size (patch_size[0],patch_size[1]) to zero, of non-overlapping patches of size (patch_size[0],patch_size[1]) to zero,
keeping only the maximum values. The output has the same dimensions as keeping only the maximum values. The output has the same dimensions as
the input. the input.
Parameters Parameters
---------- ----------
input : 4-D theano tensor of input images input : 4-D theano tensor of input images
...@@ -37,6 +38,7 @@ def max_pool_2d_same_size(input, patch_size): ...@@ -37,6 +38,7 @@ def max_pool_2d_same_size(input, patch_size):
patch_size : tuple of length 2 patch_size : tuple of length 2
Size of the patch (patch height, patch width). Size of the patch (patch height, patch width).
(2,2) will retain only one non-zero value per patch of 4 values. (2,2) will retain only one non-zero value per patch of 4 values.
""" """
output = Pool(patch_size, True)(input) output = Pool(patch_size, True)(input)
outs = MaxPoolGrad(patch_size, True)(input, output, output) outs = MaxPoolGrad(patch_size, True)(input, output, output)
...@@ -49,6 +51,7 @@ def pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0), ...@@ -49,6 +51,7 @@ def pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0),
Takes as input a N-D tensor, where N >= 2. It downscales the input image by Takes as input a N-D tensor, where N >= 2. It downscales the input image by
the specified factor, by keeping only the maximum value of non-overlapping the specified factor, by keeping only the maximum value of non-overlapping
patches of size (ds[0],ds[1]) patches of size (ds[0],ds[1])
Parameters Parameters
---------- ----------
input : N-D theano tensor of input images input : N-D theano tensor of input images
...@@ -71,6 +74,7 @@ def pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0), ...@@ -71,6 +74,7 @@ def pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0),
Operation executed on each window. `max` and `sum` always exclude Operation executed on each window. `max` and `sum` always exclude
the padding in the computation. `average` gives you the choice to the padding in the computation. `average` gives you the choice to
include or exclude it. include or exclude it.
""" """
if input.ndim < 2: if input.ndim < 2:
raise NotImplementedError('pool_2d requires a dimension >= 2') raise NotImplementedError('pool_2d requires a dimension >= 2')
...@@ -121,15 +125,17 @@ class Pool(Op): ...@@ -121,15 +125,17 @@ class Pool(Op):
For N-dimensional tensors, consider that the last two dimensions span For N-dimensional tensors, consider that the last two dimensions span
images. This Op downsamples these images by taking the max, sum or average images. This Op downsamples these images by taking the max, sum or average
over different patch. over different patch.
The constructor takes the max, sum or average or different input patches. The constructor takes the max, sum or average or different input patches.
Parameters Parameters
---------- ----------
ds : list or tuple of two ints ds : list or tuple of two ints
Downsample factor over rows and column. Downsample factor over rows and column.
ds indicates the pool region size. ds indicates the pool region size.
ignore_border : bool ignore_border : bool
If ds doesn't divide imgshape, do we include an extra row/col of partial If ds doesn't divide imgshape, do we include an extra row/col
downsampling (False) or ignore it (True). of partial downsampling (False) or ignore it (True).
st : list or tuple of two ints or None st : list or tuple of two ints or None
Stride size, which is the number of shifts over rows/cols to get the Stride size, which is the number of shifts over rows/cols to get the
next pool region. If st is None, it is considered equal to ds next pool region. If st is None, it is considered equal to ds
...@@ -141,6 +147,7 @@ class Pool(Op): ...@@ -141,6 +147,7 @@ class Pool(Op):
mode : {'max', 'sum', 'average_inc_pad', 'average_exc_pad'} mode : {'max', 'sum', 'average_inc_pad', 'average_exc_pad'}
('average_inc_pad' excludes the padding from the count, ('average_inc_pad' excludes the padding from the count,
'average_exc_pad' include it) 'average_exc_pad' include it)
""" """
__props__ = ('ds', 'ignore_border', 'st', 'padding', 'mode') __props__ = ('ds', 'ignore_border', 'st', 'padding', 'mode')
...@@ -150,6 +157,7 @@ class Pool(Op): ...@@ -150,6 +157,7 @@ class Pool(Op):
""" """
Return the shape of the output from this op, for input of given Return the shape of the output from this op, for input of given
shape and flags. shape and flags.
Parameters Parameters
---------- ----------
imgshape : tuple, list, or similar of integer or scalar Theano variable imgshape : tuple, list, or similar of integer or scalar Theano variable
...@@ -168,12 +176,14 @@ class Pool(Op): ...@@ -168,12 +176,14 @@ class Pool(Op):
(pad_h, pad_w), pad zeros to extend beyond four borders (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, 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. and pad_w is the size of the left and right margins.
Returns Returns
------- -------
list list
The shape of the output from this op, for input of given shape. The shape of the output from this op, for input of given shape.
This will have the same length as imgshape, but with last two This will have the same length as imgshape, but with last two
elements reduced as per the downsampling & ignore_border flags. elements reduced as per the downsampling & ignore_border flags.
""" """
if len(imgshape) < 2: if len(imgshape) < 2:
raise TypeError('imgshape must have at least two elements ' raise TypeError('imgshape must have at least two elements '
...@@ -528,27 +538,36 @@ class PoolGrad(Op): ...@@ -528,27 +538,36 @@ class PoolGrad(Op):
def out_shape(imgshape, ds, ignore_border=False, st=None, padding=(0, 0)): def out_shape(imgshape, ds, ignore_border=False, st=None, padding=(0, 0)):
"""Return the shape of the output from this op, for input of given """Return the shape of the output from this op, for input of given
shape and flags. shape and flags.
:param imgshape: the shape of a tensor of images. The last two elements
are interpreted as the number of rows, and the number of cols. Parameters
:type imgshape: tuple, list, or similar of integer or ----------
scalar Theano variable. imgshape : tuple of integers or scalar Theano variables
:param ds: downsample factor over rows and columns the shape of a tensor of images. The last two elements are
this parameter indicates the size of the pooling region interpreted as the number of rows, and the number of cols.
:type ds: list or tuple of two ints ds : tuple of two ints
:param st: the stride size. This is the distance between the pooling downsample factor over rows and columns this parameter
regions. If it's set to None, in which case it equlas ds. indicates the size of the pooling region
:type st: list or tuple of two ints st : tuple of two ints
:param ignore_border: if ds doesn't divide imgshape, do we include an the stride size. This is the distance between the pooling
extra row/col of partial downsampling (False) or ignore it (True). regions. If it's set to None, in which case it equlas ds.
:type ignore_border: bool ignore_border : bool
:param padding: (pad_h, pad_w), pad zeros to extend beyond four borders if ds doesn't divide imgshape, do we include an extra
of the images, pad_h is the size of the top and bottom margins, row/col of partial downsampling (False) or ignore it
and pad_w is the size of the left and right margins. (True).
:type padding: tuple of two ints padding : tuple of two ints
:rtype: list (pad_h, pad_w), pad zeros to extend beyond four borders of
:returns: the shape of the output from this op, for input of given the images, pad_h is the size of the top and bottom
shape. This will have the same length as imgshape, but with last margins, and pad_w is the size of the left and right
two elements reduced as per the downsampling & ignore_border flags. margins.
Returns
-------
list :
the shape of the output from this op, for input of given
shape. This will have the same length as imgshape, but
with last two elements reduced as per the downsampling &
ignore_border flags.
""" """
if len(imgshape) < 2: if len(imgshape) < 2:
raise TypeError('imgshape must have at least two elements ' raise TypeError('imgshape must have at least two elements '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论