Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
adca49c9
提交
adca49c9
authored
5月 11, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make tests test_rng_mrg.py:test_rng0 work in FAST_COMPILE and DEBUG_MODE and enabled those mode.
上级
dbc3e752
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
28 行删除
+27
-28
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+27
-28
没有找到文件。
theano/sandbox/test_rng_mrg.py
浏览文件 @
adca49c9
...
@@ -10,8 +10,7 @@ from theano.sandbox.rng_mrg import MRG_RandomStreams
...
@@ -10,8 +10,7 @@ from theano.sandbox.rng_mrg import MRG_RandomStreams
#TODO: bug fix test_normal0, in normal() fct, n_samples currently need to be numpy.prod(size) not self.n_streams(size)
#TODO: bug fix test_normal0, in normal() fct, n_samples currently need to be numpy.prod(size) not self.n_streams(size)
mode
=
theano
.
config
.
mode
mode
=
theano
.
config
.
mode
#THIS IS THEIR AS THEIR IS A MEMORY LINK in perform THAT WILL MAKE THE BUILDBOT DON'T WORK
mode
=
'FAST_RUN'
#TODO: remove this
def
test_rng0
():
def
test_rng0
():
def
basictest
(
f
,
steps
,
prefix
=
""
):
def
basictest
(
f
,
steps
,
prefix
=
""
):
...
@@ -23,9 +22,13 @@ def test_rng0():
...
@@ -23,9 +22,13 @@ def test_rng0():
ival
=
numpy
.
asarray
(
ival
)
ival
=
numpy
.
asarray
(
ival
)
if
i
==
0
:
if
i
==
0
:
mean
=
numpy
.
array
(
ival
,
copy
=
True
)
mean
=
numpy
.
array
(
ival
,
copy
=
True
)
min_
=
ival
.
min
()
max_
=
ival
.
max
()
else
:
else
:
alpha
=
1.0
/
(
1
+
i
)
alpha
=
1.0
/
(
1
+
i
)
mean
=
alpha
*
ival
+
(
1
-
alpha
)
*
mean
mean
=
alpha
*
ival
+
(
1
-
alpha
)
*
mean
min_
=
min
(
min_
,
ival
.
min
())
max_
=
max
(
max_
,
ival
.
max
())
assert
ival
.
min
()
>
0
and
ival
.
max
()
<
1
assert
ival
.
min
()
>
0
and
ival
.
max
()
<
1
print
prefix
,
'mean'
,
numpy
.
mean
(
mean
)
print
prefix
,
'mean'
,
numpy
.
mean
(
mean
)
...
@@ -33,20 +36,15 @@ def test_rng0():
...
@@ -33,20 +36,15 @@ def test_rng0():
print
prefix
,
'time'
,
dt
print
prefix
,
'time'
,
dt
print
prefix
,
'elements'
,
steps
*
sample_size
[
0
]
*
sample_size
[
1
]
print
prefix
,
'elements'
,
steps
*
sample_size
[
0
]
*
sample_size
[
1
]
print
prefix
,
'samples/sec'
,
steps
*
sample_size
[
0
]
*
sample_size
[
1
]
/
dt
print
prefix
,
'samples/sec'
,
steps
*
sample_size
[
0
]
*
sample_size
[
1
]
/
dt
if
0
:
print
prefix
,
'min'
,
min_
,
'max'
,
max_
mean
,
std
,
min
,
max
=
numpy
.
mean
(
l
),
numpy
.
std
(
l
),
numpy
.
min
(
l
),
numpy
.
max
(
l
)
if
mode
in
[
'DEBUG_MODE'
,
'FAST_COMPILE'
]:
print
prefix
,
'mean'
,
mean
sample_size
=
(
10
,
100
)
print
prefix
,
'std'
,
std
steps
=
int
(
1e2
)
print
prefix
,
'min'
,
repr
(
min
)
else
:
print
prefix
,
'max'
,
repr
(
max
)
sample_size
=
(
1000
,
100
)
steps
=
int
(
1e3
)
assert
max
<
1.0
assert
min
>=
0.0
assert
abs
(
mean
-
0.5
)
<
.
01
,
'bad mean?'
sample_size
=
(
1000
,
100
)
print
''
print
''
print
'ON CPU:'
print
'ON CPU:'
...
@@ -57,17 +55,18 @@ def test_rng0():
...
@@ -57,17 +55,18 @@ def test_rng0():
print
'random?[:10]
\n
'
,
f
()[
0
,
0
:
10
]
print
'random?[:10]
\n
'
,
f
()[
0
,
0
:
10
]
basictest
(
f
,
steps
,
prefix
=
'mrg cpu'
)
basictest
(
f
,
steps
,
prefix
=
'mrg cpu'
)
print
''
if
mode
!=
'FAST_COMPILE'
:
print
'ON GPU:'
print
''
R
=
MRG_RandomStreams
(
234
,
use_cuda
=
True
)
print
'ON GPU:'
u
=
R
.
uniform
(
size
=
sample_size
,
dtype
=
'float32'
)
R
=
MRG_RandomStreams
(
234
,
use_cuda
=
True
)
assert
u
.
dtype
==
'float32'
#well, it's really that this test w GPU doesn't make sense otw
u
=
R
.
uniform
(
size
=
sample_size
,
dtype
=
'float32'
)
f
=
theano
.
function
([],
theano
.
Out
(
assert
u
.
dtype
==
'float32'
#well, it's really that this test w GPU doesn't make sense otw
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
f
=
theano
.
function
([],
theano
.
Out
(
borrow
=
True
),
mode
=
mode
)
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
theano
.
printing
.
debugprint
(
f
)
borrow
=
True
),
mode
=
mode
)
print
'random?[:10]
\n
'
,
numpy
.
asarray
(
f
())[
0
,
0
:
10
]
theano
.
printing
.
debugprint
(
f
)
basictest
(
f
,
steps
,
prefix
=
'mrg gpu'
)
print
'random?[:10]
\n
'
,
numpy
.
asarray
(
f
())[
0
,
0
:
10
]
basictest
(
f
,
steps
,
prefix
=
'mrg gpu'
)
print
''
print
''
print
'ON CPU w NUMPY:'
print
'ON CPU w NUMPY:'
...
@@ -76,7 +75,7 @@ def test_rng0():
...
@@ -76,7 +75,7 @@ def test_rng0():
uu
=
RR
.
uniform
(
size
=
sample_size
)
uu
=
RR
.
uniform
(
size
=
sample_size
)
ff
=
theano
.
function
([],
uu
,
mode
=
mode
)
ff
=
theano
.
function
([],
uu
,
mode
=
mode
)
basictest
(
ff
,
1000
,
prefix
=
'numpy'
)
basictest
(
ff
,
steps
,
prefix
=
'numpy'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论