Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0cc0a9d9
提交
0cc0a9d9
authored
7月 09, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python 2.4 compatibility fixes
上级
12152e3d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
8 行删除
+22
-8
basic.py
theano/sparse/basic.py
+1
-0
sp.py
theano/sparse/sandbox/sp.py
+21
-8
没有找到文件。
theano/sparse/basic.py
浏览文件 @
0cc0a9d9
...
...
@@ -16,6 +16,7 @@ from theano import tensor
from
theano
import
compile
from
theano
import
scalar
from
theano
import
config
from
theano.gof.python25
import
all
,
any
#TODO: move this decorator to the compile submodule
def
register_specialize
(
lopt
,
*
tags
,
**
kwargs
):
...
...
theano/sparse/sandbox/sp.py
浏览文件 @
0cc0a9d9
...
...
@@ -13,6 +13,7 @@ from scipy import sparse as scipy_sparse
import
theano
import
theano.sparse
from
theano
import
sparse
,
gof
,
Op
,
tensor
from
theano.gof.python25
import
all
,
any
from
theano.printing
import
Print
def
register_specialize
(
lopt
,
*
tags
,
**
kwargs
):
...
...
@@ -346,16 +347,22 @@ class ConvolutionIndices(Op):
insize
=
N
.
prod
(
inshp
)
# range of output units over which to iterate
lbound
=
N
.
array
([
kshp
[
0
]
-
1
,
kshp
[
1
]
-
1
])
if
mode
==
'valid'
else
N
.
zeros
(
2
)
ubound
=
lbound
+
(
inshp
[
1
:]
-
kshp
+
1
)
if
mode
==
'valid'
else
fulloutshp
if
mode
==
'valid'
:
lbound
=
N
.
array
([
kshp
[
0
]
-
1
,
kshp
[
1
]
-
1
])
ubound
=
lbound
+
(
inshp
[
1
:]
-
kshp
+
1
)
else
:
lbound
=
N
.
zeros
(
2
)
ubound
=
fulloutshp
# coordinates of image in "fulloutshp" coordinates
topleft
=
N
.
array
([
kshp
[
0
]
-
1
,
kshp
[
1
]
-
1
])
botright
=
topleft
+
inshp
[
1
:]
# bound when counting the receptive field
# sparse matrix specifics...
spmatshp
=
(
outsize
*
N
.
prod
(
kshp
)
*
inshp
[
0
],
insize
)
if
ws
else
\
(
nkern
*
outsize
,
insize
)
if
ws
:
spmatshp
=
(
outsize
*
N
.
prod
(
kshp
)
*
inshp
[
0
],
insize
)
else
:
spmatshp
=
(
nkern
*
outsize
,
insize
)
spmat
=
scipy_sparse
.
lil_matrix
(
spmatshp
)
# loop over output image pixels
...
...
@@ -396,11 +403,16 @@ class ConvolutionIndices(Op):
fmapi
*
N
.
prod
(
inshp
[
1
:])
# taking into account multiple input features
# convert oy,ox values to output space coordinates
(
y
,
x
)
=
(
oy
,
ox
)
if
mode
==
'full'
else
(
oy
,
ox
)
-
topleft
if
mode
==
'full'
:
(
y
,
x
)
=
(
oy
,
ox
)
else
:
(
y
,
x
)
=
(
oy
,
ox
)
-
topleft
(
y
,
x
)
=
N
.
array
([
y
,
x
])
/
(
dy
,
dx
)
# taking into account step size
# convert to row index of sparse matrix
row
=
(
y
*
outshp
[
1
]
+
x
)
*
inshp
[
0
]
*
ksize
+
l
+
fmapi
*
ksize
if
ws
else
\
y
*
outshp
[
1
]
+
x
if
ws
:
row
=
(
y
*
outshp
[
1
]
+
x
)
*
inshp
[
0
]
*
ksize
+
l
+
fmapi
*
ksize
else
:
row
=
y
*
outshp
[
1
]
+
x
# Store something at that location in sparse matrix.
# The written value is only useful for the sparse case. It
...
...
@@ -444,7 +456,8 @@ class ConvolutionIndices(Op):
rval
=
(
spmat
.
indices
[:
spmat
.
size
],
spmat
.
indptr
,
spmatshp
,
sptype
,
outshp
)
rval
+=
(
kmap
,)
if
kmap
!=
None
else
()
if
kmap
is
not
None
:
rval
+=
(
kmap
,)
return
rval
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论