提交 f2c57a5f authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/sandbox/neighbourhoods.py

上级 69911d9c
"""WARNING: This code is not recommanded. It is not finished, it is """
slower then the version in sandbox/neighbours.py, and it do not work .. warning:: This code is not recommanded. It is not finished, it is
slower than the version in sandbox/neighbours.py, and it does not work
on the GPU. on the GPU.
We only keep this version here as it is a little bit more generic, so We only keep this version here as it is a little bit more generic, so
...@@ -16,15 +17,9 @@ from theano import gof, Op ...@@ -16,15 +17,9 @@ from theano import gof, Op
class NeighbourhoodsFromImages(Op): class NeighbourhoodsFromImages(Op):
__props__ = ("n_dims_before", "dims_neighbourhoods", "strides",
"ignore_border", "inverse")
def __init__(self, n_dims_before, dims_neighbourhoods,
strides=None, ignore_border=False, inverse=False):
""" """
This extracts neighbourhoods from "images", but in a This extracts neighbourhoods from "images", but in a dimension-generic
dimension-generic manner. manner.
In the 2D case, this is similar to downsampling, but instead of reducing In the 2D case, this is similar to downsampling, but instead of reducing
a group of 2x2 pixels (for example) to a single new pixel in the output, a group of 2x2 pixels (for example) to a single new pixel in the output,
...@@ -40,21 +35,20 @@ class NeighbourhoodsFromImages(Op): ...@@ -40,21 +35,20 @@ class NeighbourhoodsFromImages(Op):
[ [ [ 0.5, 0.6, 0.1, 0.2 ] ], # the first 2x2 group of pixels [ [ [ 0.5, 0.6, 0.1, 0.2 ] ], # the first 2x2 group of pixels
[ [ 0.7, 0.8, 0.3, 0.4 ] ] ] # the second one [ [ 0.7, 0.8, 0.3, 0.4 ] ] ] # the second one
so think of a 2D downsampling where each pixel of the resulting array So think of a 2D downsampling where each pixel of the resulting array
is replaced by an array containing the (flattened) pixels of the is replaced by an array containing the (flattened) pixels of the
corresponding neighbourhood. corresponding neighbourhood.
If you provide a stack of 2D image, or multiple stacks, each image If you provide a stack of 2D images, or multiple stacks, each image
will be treated independently, and the first dimensions of the array will be treated independently, and the first dimensions of the array
will be preserved as such. will be preserved as such.
This also makes sense in the 1D or 3D case. Below I'll still be calling This also makes sense in the 1D or 3D case. Below I'll still be calling
those "images", by analogy. those "images", by analogy.
In the 1D case, you're In the 1D case, you're extracting subsequences from the original sequence.
extracting subsequences from the original sequence. In the 3D case, In the 3D case, you're extracting cuboids.
you're extracting cuboids. If you ever find a 4D use, tell me! It If you ever find a 4D use, tell me! It should be possible, anyhow.
should be possible, anyhow.
Parameters Parameters
---------- ----------
...@@ -75,7 +69,15 @@ class NeighbourhoodsFromImages(Op): ...@@ -75,7 +69,15 @@ class NeighbourhoodsFromImages(Op):
inverse : bool inverse : bool
You shouldn't have to use this. Only used by child class You shouldn't have to use this. Only used by child class
ImagesFromNeighbourhoods which simply reverses the assignment. ImagesFromNeighbourhoods which simply reverses the assignment.
""" """
__props__ = ("n_dims_before", "dims_neighbourhoods", "strides",
"ignore_border", "inverse")
def __init__(self, n_dims_before, dims_neighbourhoods,
strides=None, ignore_border=False, inverse=False):
self.n_dims_before = n_dims_before self.n_dims_before = n_dims_before
self.dims_neighbourhoods = dims_neighbourhoods self.dims_neighbourhoods = dims_neighbourhoods
if strides is not None: if strides is not None:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论