Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
74421e0b
提交
74421e0b
authored
3月 23, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed indentation
上级
d464ec4c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
22 行删除
+22
-22
test_ifelse.py
theano/tests/test_ifelse.py
+10
-10
test_rop.py
theano/tests/test_rop.py
+12
-12
没有找到文件。
theano/tests/test_ifelse.py
浏览文件 @
74421e0b
...
@@ -231,13 +231,13 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -231,13 +231,13 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
def
test_multiple_out_crash
(
self
):
def
test_multiple_out_crash
(
self
):
# This test failed up to commit 2faeb62c38
# This test failed up to commit 2faeb62c38
p0
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
([
4
,
8
]),
p0
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
([
4
,
8
]),
dtype
=
self
.
dtype
))
dtype
=
self
.
dtype
))
p1
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
(
8
),
p1
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
(
8
),
dtype
=
self
.
dtype
))
dtype
=
self
.
dtype
))
p2
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
([
8
,
3
]),
p2
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
([
8
,
3
]),
dtype
=
self
.
dtype
))
dtype
=
self
.
dtype
))
p3
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
(
3
),
p3
=
self
.
shared
(
np
.
asarray
(
np
.
random
.
random
(
3
),
dtype
=
self
.
dtype
))
dtype
=
self
.
dtype
))
p
=
[
p0
,
p1
,
p2
,
p3
]
p
=
[
p0
,
p1
,
p2
,
p3
]
# in my code these vars are the result of applying scan
# in my code these vars are the result of applying scan
...
@@ -384,9 +384,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -384,9 +384,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
vw2
=
rng
.
uniform
()
vw2
=
rng
.
uniform
()
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
vx1
*
vy1
*
vw1
)
vx1
*
vy1
*
vw1
)
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
vx2
*
vy2
*
vw2
)
vx2
*
vy2
*
vw2
)
def
test_pushout3
(
self
):
def
test_pushout3
(
self
):
raise
SkipTest
(
"Optimization temporarily disabled"
)
raise
SkipTest
(
"Optimization temporarily disabled"
)
...
@@ -440,14 +440,14 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -440,14 +440,14 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
else
:
else
:
vw
=
vw2
vw
=
vw2
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
vx1
*
vy1
*
vw
)
vx1
*
vy1
*
vw
)
if
vx2
>
vy2
:
if
vx2
>
vy2
:
vw
=
vw1
vw
=
vw1
else
:
else
:
vw
=
vw2
vw
=
vw2
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
vx2
*
vy2
*
vw
)
vx2
*
vy2
*
vw
)
def
test_merge_ifs_true_false
(
self
):
def
test_merge_ifs_true_false
(
self
):
raise
SkipTest
(
"Optimization temporarily disabled"
)
raise
SkipTest
(
"Optimization temporarily disabled"
)
...
@@ -475,9 +475,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -475,9 +475,9 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
vw1
=
rng
.
uniform
()
vw1
=
rng
.
uniform
()
vw2
=
rng
.
uniform
()
vw2
=
rng
.
uniform
()
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
1
),
vx1
+
vy1
+
vw1
)
vx1
+
vy1
+
vw1
)
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
assert
np
.
allclose
(
f
(
vx1
,
vx2
,
vy1
,
vy2
,
vw1
,
vw2
,
0
),
vx2
+
vy2
+
vw2
)
vx2
+
vy2
+
vw2
)
def
test_grad_test_values
(
self
):
def
test_grad_test_values
(
self
):
"""
"""
...
...
theano/tests/test_rop.py
浏览文件 @
74421e0b
...
@@ -104,9 +104,9 @@ class RopLop_checker(unittest.TestCase):
...
@@ -104,9 +104,9 @@ class RopLop_checker(unittest.TestCase):
after the Op you want to test.
after the Op you want to test.
"""
"""
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
mat_in_shape
),
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
mat_in_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
mat_in_shape
),
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
mat_in_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
yv
=
tensor
.
Rop
(
y
,
self
.
mx
,
self
.
mv
)
yv
=
tensor
.
Rop
(
y
,
self
.
mx
,
self
.
mv
)
rop_f
=
function
([
self
.
mx
,
self
.
mv
],
yv
,
on_unused_input
=
'ignore'
)
rop_f
=
function
([
self
.
mx
,
self
.
mv
],
yv
,
on_unused_input
=
'ignore'
)
sy
,
_
=
theano
.
scan
(
lambda
i
,
y
,
x
,
v
:
sy
,
_
=
theano
.
scan
(
lambda
i
,
y
,
x
,
v
:
...
@@ -141,9 +141,9 @@ class RopLop_checker(unittest.TestCase):
...
@@ -141,9 +141,9 @@ class RopLop_checker(unittest.TestCase):
"""
"""
# TEST ROP
# TEST ROP
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
yv
=
tensor
.
Rop
(
y
,
self
.
x
,
self
.
v
)
yv
=
tensor
.
Rop
(
y
,
self
.
x
,
self
.
v
)
rop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
rop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
...
@@ -166,9 +166,9 @@ class RopLop_checker(unittest.TestCase):
...
@@ -166,9 +166,9 @@ class RopLop_checker(unittest.TestCase):
# TEST LOP
# TEST LOP
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
vx
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
self
.
in_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
out_shape
),
vv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
out_shape
),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
yv
=
tensor
.
Lop
(
y
,
self
.
x
,
self
.
v
)
yv
=
tensor
.
Lop
(
y
,
self
.
x
,
self
.
v
)
lop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
lop_f
=
function
([
self
.
x
,
self
.
v
],
yv
,
on_unused_input
=
'ignore'
)
...
@@ -214,21 +214,21 @@ class test_RopLop(RopLop_checker):
...
@@ -214,21 +214,21 @@ class test_RopLop(RopLop_checker):
def
test_incsubtensor1
(
self
):
def
test_incsubtensor1
(
self
):
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
3
,)),
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
3
,)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
t
=
theano
.
shared
(
tv
)
t
=
theano
.
shared
(
tv
)
out
=
tensor
.
inc_subtensor
(
self
.
x
[:
3
],
t
)
out
=
tensor
.
inc_subtensor
(
self
.
x
[:
3
],
t
)
self
.
check_rop_lop
(
out
,
self
.
in_shape
)
self
.
check_rop_lop
(
out
,
self
.
in_shape
)
def
test_incsubtensor2
(
self
):
def
test_incsubtensor2
(
self
):
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
t
=
theano
.
shared
(
tv
)
t
=
theano
.
shared
(
tv
)
out
=
tensor
.
inc_subtensor
(
t
[:
4
],
self
.
x
[:
4
])
out
=
tensor
.
inc_subtensor
(
t
[:
4
],
self
.
x
[:
4
])
self
.
check_rop_lop
(
out
,
(
10
,))
self
.
check_rop_lop
(
out
,
(
10
,))
def
test_setsubtensor1
(
self
):
def
test_setsubtensor1
(
self
):
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
3
,)),
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
3
,)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
t
=
theano
.
shared
(
tv
)
t
=
theano
.
shared
(
tv
)
out
=
tensor
.
set_subtensor
(
self
.
x
[:
3
],
t
)
out
=
tensor
.
set_subtensor
(
self
.
x
[:
3
],
t
)
self
.
check_rop_lop
(
out
,
self
.
in_shape
)
self
.
check_rop_lop
(
out
,
self
.
in_shape
)
...
@@ -239,7 +239,7 @@ class test_RopLop(RopLop_checker):
...
@@ -239,7 +239,7 @@ class test_RopLop(RopLop_checker):
def
test_setsubtensor2
(
self
):
def
test_setsubtensor2
(
self
):
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
t
=
theano
.
shared
(
tv
)
t
=
theano
.
shared
(
tv
)
out
=
tensor
.
set_subtensor
(
t
[:
4
],
self
.
x
[:
4
])
out
=
tensor
.
set_subtensor
(
t
[:
4
],
self
.
x
[:
4
])
self
.
check_rop_lop
(
out
,
(
10
,))
self
.
check_rop_lop
(
out
,
(
10
,))
...
@@ -347,7 +347,7 @@ class test_RopLop(RopLop_checker):
...
@@ -347,7 +347,7 @@ class test_RopLop(RopLop_checker):
def
test_join
(
self
):
def
test_join
(
self
):
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
tv
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
10
,)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
t
=
theano
.
shared
(
tv
)
t
=
theano
.
shared
(
tv
)
out
=
tensor
.
join
(
0
,
self
.
x
,
t
)
out
=
tensor
.
join
(
0
,
self
.
x
,
t
)
self
.
check_rop_lop
(
out
,
(
self
.
in_shape
[
0
]
+
10
,))
self
.
check_rop_lop
(
out
,
(
self
.
in_shape
[
0
]
+
10
,))
...
@@ -355,7 +355,7 @@ class test_RopLop(RopLop_checker):
...
@@ -355,7 +355,7 @@ class test_RopLop(RopLop_checker):
def
test_dot
(
self
):
def
test_dot
(
self
):
insh
=
self
.
in_shape
[
0
]
insh
=
self
.
in_shape
[
0
]
vW
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
insh
,
insh
)),
vW
=
np
.
asarray
(
self
.
rng
.
uniform
(
size
=
(
insh
,
insh
)),
theano
.
config
.
floatX
)
theano
.
config
.
floatX
)
W
=
theano
.
shared
(
vW
)
W
=
theano
.
shared
(
vW
)
self
.
check_rop_lop
(
tensor
.
dot
(
self
.
x
,
W
),
self
.
in_shape
)
self
.
check_rop_lop
(
tensor
.
dot
(
self
.
x
,
W
),
self
.
in_shape
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论