Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f2c57a5f
提交
f2c57a5f
authored
8月 07, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/sandbox/neighbourhoods.py
上级
69911d9c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
54 行增加
和
52 行删除
+54
-52
neighbourhoods.py
theano/sandbox/neighbourhoods.py
+54
-52
没有找到文件。
theano/sandbox/neighbourhoods.py
浏览文件 @
f2c57a5f
"""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,66 +17,67 @@ from theano import gof, Op
...
@@ -16,66 +17,67 @@ from theano import gof, Op
class
NeighbourhoodsFromImages
(
Op
):
class
NeighbourhoodsFromImages
(
Op
):
"""
This extracts neighbourhoods from "images", but in a dimension-generic
manner.
__props__
=
(
"n_dims_before"
,
"dims_neighbourhoods"
,
"strides"
,
In the 2D case, this is similar to downsampling, but instead of reducing
"ignore_border"
,
"inverse"
)
a group of 2x2 pixels (for example) to a single new pixel in the output,
you place those 4 pixels in a row.
def
__init__
(
self
,
n_dims_before
,
dims_neighbourhoods
,
strides
=
None
,
ignore_border
=
False
,
inverse
=
False
):
"""
This extracts neighbourhoods from "images", but in a
dimension-generic manner.
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,
you place those 4 pixels in a row.
For example, say you have this 2x4 image::
For example, say you have this 2x4 image::
[ [ 0.5, 0.6, 0.7, 0.8 ],
[ [ 0.5, 0.6, 0.7, 0.8 ],
[ 0.1, 0.2, 0.3, 0.4 ] ]
[ 0.1, 0.2, 0.3, 0.4 ] ]
and you want to extract 2x2 neighbourhoods. This op would then produce::
and you want to extract 2x2 neighbourhoods. This op would then produce::
[ [ [ 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
----------
----------
n_dims_before : int
n_dims_before : int
Number of dimensions preceding the "images".
Number of dimensions preceding the "images".
dims_neighbourhoods : tuple of ints
dims_neighbourhoods : tuple of ints
Exact shape of windows to be extracted (e.g. (2,2) in the case above).
Exact shape of windows to be extracted (e.g. (2,2) in the case above).
n_dims_before + len(dims_neighbourhoods) should be equal to the
n_dims_before + len(dims_neighbourhoods) should be equal to the
number of dimensions in the input given to the op.
number of dimensions in the input given to the op.
strides : tuple of int
strides : tuple of int
Number of elements to skip when moving to the next neighbourhood,
Number of elements to skip when moving to the next neighbourhood,
for each dimension of dims_neighbourhoods. There can be overlap
for each dimension of dims_neighbourhoods. There can be overlap
between neighbourhoods, or gaps.
between neighbourhoods, or gaps.
ignore_border : bool
ignore_border : bool
If the dimensions of the neighbourhoods don't exactly divide the
If the dimensions of the neighbourhoods don't exactly divide the
dimensions of the "images", you can either fill the last
dimensions of the "images", you can either fill the last
neighbourhood with zeros (False) or drop it entirely (True).
neighbourhood with zeros (False) or drop it entirely (True).
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论