Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0a62c9df
提交
0a62c9df
authored
5月 19, 2010
作者:
Pierre-Antoine Manzagol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove experiemental conv_2d_offset code.
上级
b3b502cd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
87 行删除
+0
-87
conv.py
theano/tensor/nnet/conv.py
+0
-87
没有找到文件。
theano/tensor/nnet/conv.py
浏览文件 @
0a62c9df
...
@@ -83,93 +83,6 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
...
@@ -83,93 +83,6 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
return
op
(
input
,
filters
)
return
op
(
input
,
filters
)
def
conv2d_offset
(
input
,
filters
,
image_shape
=
None
,
filter_shape
=
None
,
border_mode
=
'valid'
,
subsample
=
(
1
,
1
),
offsets
=
[],
**
kargs
):
"""
Build a graph for nnet convolutions with subsampling and offsetting.
Refer to conv2d for a general explanation of the context.
*Subsampling* means, we only compute convolutions at a fraction of the
sites. *Offsetting* convolutions in the context of subsampling means not
computing all of them at the same sites (starting in upper left corner).
This function allows offsets to be used.
Most parameters are shared with conv2d, except:
:param offsets: list of 2-tuples that specify sites wrt the subsampling
scheme. The filters are split evenly accross the different sites. For
example with subsample (2,2) we can use the sites [(0,0), (0,1), (1,0),
(1,1)]. An empty list is interpreted as all offsets.
"""
# There should be subsampling for offsets to make any sense.
if
not
(
subsample
[
0
]
>
1
or
subsample
[
1
]
>
1
):
raise
ValueError
(
'conv2d_offset requires subsampling.'
)
# Haven't thought about this case.
if
numpy
.
any
(
numpy
.
array
(
subsample
)
>
filter_shape
[
2
:]):
raise
ValueError
(
'conv2d_offset subsample greater than filter shape. Not supported?'
)
# No offsets specified is interpreted as all offsets.
if
len
(
offsets
)
==
0
:
offsets
=
[]
for
i
in
range
(
subsample
[
0
]):
for
j
in
range
(
subsample
[
1
]):
offsets
.
append
((
i
,
j
))
# Find the largest offsets in both image dimensions. Used to determine the
# size of the image used.
max_offset
=
list
(
offsets
[
0
])
for
offset
in
offsets
:
if
offset
[
0
]
>
max_offset
[
0
]:
max_offset
[
0
]
=
offset
[
0
]
if
offset
[
1
]
>
max_offset
[
1
]:
max_offset
[
1
]
=
offset
[
1
]
if
not
(
max_offset
[
0
]
<
subsample
[
0
]
and
max_offset
[
1
]
<
subsample
[
1
]):
raise
ValueError
(
'conv2d_offset: invalid offset sites.'
)
# Determine the reduced size of input so all feature maps get an input of
# the same size.
sub_image_shape
=
list
(
image_shape
)
sub_image_shape
[
2
]
-=
max_offset
[
0
]
sub_image_shape
[
3
]
-=
max_offset
[
1
]
# Determine number of filters per offset position.
if
(
filter_shape
[
0
]
%
len
(
offsets
))
!=
0
:
print
'nfilts '
,
filter_shape
[
0
],
' noffsets '
,
len
(
offsets
)
raise
ValueError
(
'conv2d_offset: invalid number of filters wrt offsets.'
)
n_filters
=
filter_shape
[
0
]
/
len
(
offsets
)
sub_filter_shape
=
list
(
filter_shape
)
sub_filter_shape
[
0
]
=
n_filters
# Call conv2d at each offset using same fraction of kernels.
outputs
=
[]
for
i
,
offset
in
enumerate
(
offsets
):
# Crop the input so all offsets get an input of the same size.
sub_input
=
input
[:,
:,
offset
[
0
]:
sub_image_shape
[
2
]
+
offset
[
0
],
offset
[
1
]:
sub_image_shape
[
3
]
+
offset
[
1
]]
# Grab part of the filters.
sub_filters
=
filters
[
i
*
n_filters
:(
i
+
1
)
*
n_filters
]
out
=
conv2d
(
sub_input
,
sub_filters
,
sub_image_shape
,
sub_filter_shape
,
border_mode
=
border_mode
,
subsample
=
subsample
,
**
kargs
)
outputs
.
append
(
out
)
# Join the outputs on the leading axis.
if
len
(
outputs
)
>
1
:
output
=
tensor
.
join
(
1
,
*
outputs
)
else
:
output
=
outputs
[
0
]
outshp
=
ConvOp
.
getOutputShape
(
sub_image_shape
[
2
:],
filter_shape
[
2
:],
subsample
,
border_mode
)
return
[
output
,
outshp
]
class
ConvOp
(
Op
):
class
ConvOp
(
Op
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论