Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
13479941
提交
13479941
authored
7月 28, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remplace T. by tensor.
上级
b879aa80
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
22 行删除
+21
-22
test_sp.py
theano/sparse/sandbox/test_sp.py
+21
-22
没有找到文件。
theano/sparse/sandbox/test_sp.py
浏览文件 @
13479941
...
@@ -12,9 +12,8 @@ from scipy.signal import convolve2d
...
@@ -12,9 +12,8 @@ from scipy.signal import convolve2d
import
scipy.sparse
as
sparse
import
scipy.sparse
as
sparse
import
numpy
import
numpy
from
theano
import
function
from
theano
import
function
,
tensor
import
theano
import
theano
import
theano.tensor
as
T
from
theano.sparse.sandbox
import
sp
from
theano.sparse.sandbox
import
sp
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
...
@@ -34,9 +33,9 @@ class TestSP(unittest.TestCase):
...
@@ -34,9 +33,9 @@ class TestSP(unittest.TestCase):
convmodes
=
(
'full'
,
'valid'
)
convmodes
=
(
'full'
,
'valid'
)
# symbolic stuff
# symbolic stuff
bias
=
T
.
dvector
()
bias
=
tensor
.
dvector
()
kerns
=
T
.
dmatrix
()
kerns
=
tensor
.
dmatrix
()
input
=
T
.
dmatrix
()
input
=
tensor
.
dmatrix
()
rng
=
numpy
.
random
.
RandomState
(
3423489
)
rng
=
numpy
.
random
.
RandomState
(
3423489
)
filters
=
rng
.
randn
(
nkern
,
numpy
.
prod
(
kshp
))
filters
=
rng
.
randn
(
nkern
,
numpy
.
prod
(
kshp
))
biasvals
=
rng
.
randn
(
nkern
)
biasvals
=
rng
.
randn
(
nkern
)
...
@@ -90,7 +89,7 @@ class TestSP(unittest.TestCase):
...
@@ -90,7 +89,7 @@ class TestSP(unittest.TestCase):
assert
(
temp
<
1e-5
)
.
all
()
assert
(
temp
<
1e-5
)
.
all
()
# test downward propagation -- symbolic stuff
# test downward propagation -- symbolic stuff
#vis =
T
.grad(output, input, output)
#vis =
tensor
.grad(output, input, output)
#downprop = function([kerns,input], vis, mode=mode)
#downprop = function([kerns,input], vis, mode=mode)
#visval = downprop(filters,img1d)
#visval = downprop(filters,img1d)
## test downward propagation -- reference implementation
## test downward propagation -- reference implementation
...
@@ -139,9 +138,9 @@ class TestSP(unittest.TestCase):
...
@@ -139,9 +138,9 @@ class TestSP(unittest.TestCase):
convmodes
=
(
'full'
,
'valid'
,)
convmodes
=
(
'full'
,
'valid'
,)
# symbolic stuff
# symbolic stuff
bias
=
T
.
dvector
()
bias
=
tensor
.
dvector
()
kerns
=
T
.
dvector
()
kerns
=
tensor
.
dvector
()
input
=
T
.
dmatrix
()
input
=
tensor
.
dmatrix
()
rng
=
numpy
.
random
.
RandomState
(
3423489
)
rng
=
numpy
.
random
.
RandomState
(
3423489
)
import
theano.gof
as
gof
import
theano.gof
as
gof
...
@@ -197,7 +196,7 @@ class TestSP(unittest.TestCase):
...
@@ -197,7 +196,7 @@ class TestSP(unittest.TestCase):
assert
(
temp
<
1e-10
)
.
all
()
assert
(
temp
<
1e-10
)
.
all
()
# test downward propagation
# test downward propagation
vis
=
T
.
grad
(
0.5
*
T
.
sqr
(
output
)
.
sum
(),
input
)
vis
=
tensor
.
grad
(
0.5
*
tensor
.
sqr
(
output
)
.
sum
(),
input
)
downprop
=
function
([
kerns
,
output
],
vis
)
downprop
=
function
([
kerns
,
output
],
vis
)
temp1
=
time
.
time
()
temp1
=
time
.
time
()
for
zz
in
range
(
100
):
for
zz
in
range
(
100
):
...
@@ -224,8 +223,8 @@ class TestSP(unittest.TestCase):
...
@@ -224,8 +223,8 @@ class TestSP(unittest.TestCase):
convmodes
=
(
'full'
,
'valid'
,)
convmodes
=
(
'full'
,
'valid'
,)
# symbolic stuff
# symbolic stuff
kerns
=
[
T
.
dvector
(),
T
.
dvector
()]
kerns
=
[
tensor
.
dvector
(),
tensor
.
dvector
()]
input
=
T
.
dmatrix
()
input
=
tensor
.
dmatrix
()
rng
=
numpy
.
random
.
RandomState
(
3423489
)
rng
=
numpy
.
random
.
RandomState
(
3423489
)
# build actual input images
# build actual input images
...
@@ -262,8 +261,8 @@ class TestSP(unittest.TestCase):
...
@@ -262,8 +261,8 @@ class TestSP(unittest.TestCase):
convmodes
=
(
'full'
,)
#'valid',)
convmodes
=
(
'full'
,)
#'valid',)
# symbolic stuff
# symbolic stuff
kerns
=
[
T
.
dmatrix
(),
T
.
dmatrix
()]
kerns
=
[
tensor
.
dmatrix
(),
tensor
.
dmatrix
()]
input
=
T
.
dmatrix
()
input
=
tensor
.
dmatrix
()
rng
=
numpy
.
random
.
RandomState
(
3423489
)
rng
=
numpy
.
random
.
RandomState
(
3423489
)
# build actual input images
# build actual input images
...
@@ -301,7 +300,7 @@ class TestSP(unittest.TestCase):
...
@@ -301,7 +300,7 @@ class TestSP(unittest.TestCase):
maxpoolshps
=
((
2
,
2
),(
3
,
3
),(
4
,
4
),(
5
,
5
),(
6
,
6
))
maxpoolshps
=
((
2
,
2
),(
3
,
3
),(
4
,
4
),(
5
,
5
),(
6
,
6
))
imval
=
numpy
.
random
.
rand
(
4
,
5
,
10
,
10
)
imval
=
numpy
.
random
.
rand
(
4
,
5
,
10
,
10
)
images
=
T
.
dmatrix
()
images
=
tensor
.
dmatrix
()
for
maxpoolshp
in
maxpoolshps
:
for
maxpoolshp
in
maxpoolshps
:
# symbolic stuff
# symbolic stuff
...
@@ -340,10 +339,10 @@ class TestSP(unittest.TestCase):
...
@@ -340,10 +339,10 @@ class TestSP(unittest.TestCase):
#convmodes = ('full','valid',)
#convmodes = ('full','valid',)
convmodes
=
(
'full'
,)
convmodes
=
(
'full'
,)
kerns
=
T
.
dvector
()
kerns
=
tensor
.
dvector
()
indices
=
T
.
ivector
()
indices
=
tensor
.
ivector
()
indptr
=
T
.
ivector
()
indptr
=
tensor
.
ivector
()
spmat_shape
=
T
.
ivector
()
spmat_shape
=
tensor
.
ivector
()
for
mode
in
[
'FAST_COMPILE'
,
'FAST_RUN'
]:
for
mode
in
[
'FAST_COMPILE'
,
'FAST_RUN'
]:
for
conv_mode
in
convmodes
:
for
conv_mode
in
convmodes
:
...
@@ -402,7 +401,7 @@ class TestSP(unittest.TestCase):
...
@@ -402,7 +401,7 @@ class TestSP(unittest.TestCase):
def
test_diagonal
():
def
test_diagonal
():
for
K
in
1
,
5
:
for
K
in
1
,
5
:
d
=
T
.
ivector
()
d
=
tensor
.
ivector
()
sd
=
sp
.
square_diagonal
(
d
)
sd
=
sp
.
square_diagonal
(
d
)
...
@@ -446,7 +445,7 @@ def test_row_scale():
...
@@ -446,7 +445,7 @@ def test_row_scale():
assert
numpy
.
all
(
f
(
x_val
,
s_val
)
.
toarray
()
==
(
x_val_dense
.
T
*
s_val
)
.
T
)
assert
numpy
.
all
(
f
(
x_val
,
s_val
)
.
toarray
()
==
(
x_val_dense
.
T
*
s_val
)
.
T
)
if
0
:
if
0
:
T
.
verify_grad
(
None
,
d
,
[
x_val
,
s_val
],
tensor
.
verify_grad
(
None
,
d
,
[
x_val
,
s_val
],
mode
=
theano
.
Mode
(
linker
=
'py'
,
optimizer
=
'fast_compile'
))
mode
=
theano
.
Mode
(
linker
=
'py'
,
optimizer
=
'fast_compile'
))
else
:
else
:
print
>>
sys
.
stderr
,
"WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
print
>>
sys
.
stderr
,
"WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
...
@@ -477,7 +476,7 @@ def test_col_scale():
...
@@ -477,7 +476,7 @@ def test_col_scale():
assert
numpy
.
all
(
f
(
x_val
,
s_val
)
.
toarray
()
==
(
x_val_dense
*
s_val
))
assert
numpy
.
all
(
f
(
x_val
,
s_val
)
.
toarray
()
==
(
x_val_dense
*
s_val
))
if
0
:
if
0
:
T
.
verify_grad
(
None
,
d
,
[
x_val
,
s_val
],
tensor
.
verify_grad
(
None
,
d
,
[
x_val
,
s_val
],
mode
=
theano
.
Mode
(
linker
=
'py'
,
optimizer
=
'fast_compile'
))
mode
=
theano
.
Mode
(
linker
=
'py'
,
optimizer
=
'fast_compile'
))
else
:
else
:
print
>>
sys
.
stderr
,
"WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
print
>>
sys
.
stderr
,
"WARNING: skipping gradient test because verify_grad doesn't support sparse arguments"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论