Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f7bd2274
提交
f7bd2274
authored
6月 22, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more comments in test_raw_random
上级
d5cd4c00
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
8 行删除
+27
-8
test_raw_random.py
theano/tensor/tests/test_raw_random.py
+27
-8
没有找到文件。
theano/tensor/tests/test_raw_random.py
浏览文件 @
f7bd2274
...
@@ -49,11 +49,14 @@ class T_random_function(unittest.TestCase):
...
@@ -49,11 +49,14 @@ class T_random_function(unittest.TestCase):
rng_R
=
random_state_type
()
rng_R
=
random_state_type
()
# use make_node to override some of the self.args
# use make_node to override some of the self.args
post_r2
,
out2
=
rf2
(
rng_R
,
(
4
,),
-
2
,
2
)
post_r2
,
out2
=
rf2
(
rng_R
,
(
4
,),
-
2
,
2
)
# NOT INPLACE
post_r2_4
,
out2_4
=
rf2
(
rng_R
,
(
4
,),
-
4.0
,
2
)
post_r4
,
out4
=
rf4
(
rng_R
,
(
4
,),
-
4
,
4
)
# INPLACE
post_r2_4_4
,
out2_4_4
=
rf2
(
rng_R
,
(
4
,),
-
4.0
,
4.0
)
post_r2_4
,
out2_4
=
rf2
(
rng_R
,
(
4
,),
-
4.0
,
2
)
# NOT INPLACE
post_r4
,
out4
=
rf4
(
rng_R
,
(
4
,),
-
4
,
4
)
post_r2_4_4
,
out2_4_4
=
rf2
(
rng_R
,
(
4
,),
-
4.0
,
4.0
)
# NOT INPLACE
# configure out4 to be computed inplace
# The update expression means that the random state rng_R will
# be maintained by post_r4
f
=
compile
.
function
(
f
=
compile
.
function
(
[
compile
.
In
(
rng_R
,
[
compile
.
In
(
rng_R
,
value
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
()),
value
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
()),
...
@@ -65,9 +68,25 @@ class T_random_function(unittest.TestCase):
...
@@ -65,9 +68,25 @@ class T_random_function(unittest.TestCase):
f2
,
f4
,
f2_4
,
f2_4_4
=
f
()
f2
,
f4
,
f2_4
,
f2_4_4
=
f
()
f2b
,
f4b
,
f2_4b
,
f2_4_4b
=
f
()
f2b
,
f4b
,
f2_4b
,
f2_4_4b
=
f
()
assert
numpy
.
allclose
(
f2
*
2
,
f4
)
print
f2
assert
numpy
.
allclose
(
f2_4_4
,
f4
)
print
f4
assert
not
numpy
.
allclose
(
f4
,
f4b
)
print
f2_4
print
f2_4_4
#print f2b
#print f4b
#print f2_4b
#print f2_4_4b
# setting bounds is same as multiplying by 2
assert
numpy
.
allclose
(
f2
*
2
,
f4
),
(
f2
,
f4
)
# retrieving from non-inplace generator
# is same as inplace one for first call
assert
numpy
.
allclose
(
f2_4_4
,
f4
),
(
f2_4_4
,
f4
)
# f4 changes from call to call, that the update has worked
assert
not
numpy
.
allclose
(
f4
,
f4b
),
(
f4
,
f4b
)
def
test_inplace_optimization
(
self
):
def
test_inplace_optimization
(
self
):
"""Test that FAST_RUN includes the random_make_inplace optimization"""
"""Test that FAST_RUN includes the random_make_inplace optimization"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论