Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
66344ce3
提交
66344ce3
authored
1月 26, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
small code clean up.
上级
d167b60c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
13 行删除
+9
-13
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+9
-13
没有找到文件。
theano/sandbox/test_rng_mrg.py
浏览文件 @
66344ce3
...
@@ -323,9 +323,6 @@ def test_uniform():
...
@@ -323,9 +323,6 @@ def test_uniform():
#TODO: test ndim!=size.ndim
#TODO: test ndim!=size.ndim
#TODO: test bad seed
#TODO: test bad seed
#TODO: test size=Var, with shape that change from call to call
#TODO: test size=Var, with shape that change from call to call
import
pickle
if
mode
in
[
'DEBUG_MODE'
,
'DebugMode'
,
'FAST_COMPILE'
]:
if
mode
in
[
'DEBUG_MODE'
,
'DebugMode'
,
'FAST_COMPILE'
]:
sample_size
=
(
10
,
100
)
sample_size
=
(
10
,
100
)
steps
=
50
steps
=
50
...
@@ -339,9 +336,10 @@ def test_uniform():
...
@@ -339,9 +336,10 @@ def test_uniform():
(
x
.
shape
,
[
x
],
[
numpy
.
zeros
(
sample_size
,
dtype
=
config
.
floatX
)])
(
x
.
shape
,
[
x
],
[
numpy
.
zeros
(
sample_size
,
dtype
=
config
.
floatX
)])
]:
]:
#### TEST CPU (C) IMPLEMENTATION ####
#### TEST CPU IMPLEMENTATION ####
# The python and C implementation are tested with DebugMode
print
''
print
''
print
'ON CPU
(C)
with size=(
%
s):'
%
str
(
size
)
print
'ON CPU with size=(
%
s):'
%
str
(
size
)
x
=
tensor
.
matrix
()
x
=
tensor
.
matrix
()
R
=
MRG_RandomStreams
(
234
,
use_cuda
=
False
)
R
=
MRG_RandomStreams
(
234
,
use_cuda
=
False
)
u
=
R
.
uniform
(
size
=
size
)
u
=
R
.
uniform
(
size
=
size
)
...
@@ -349,14 +347,13 @@ def test_uniform():
...
@@ -349,14 +347,13 @@ def test_uniform():
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
mrg_uniform
)
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
mrg_uniform
)
for
node
in
f
.
maker
.
env
.
toposort
()])
for
node
in
f
.
maker
.
env
.
toposort
()])
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
cpu_c_out
=
f
(
*
input
)
cpu_out
=
f
(
*
input
)
#pickle.dump(cpu_c_out, open('debug_rng_cpu_c.pkl','w'))
print
'random?[:10]
\n
'
print
'random?[:10]
\n
'
print
cpu_
c_
out
[
0
,
0
:
10
]
print
cpu_out
[
0
,
0
:
10
]
print
cpu_
c_
out
[
-
1
,
0
:
10
]
print
cpu_out
[
-
1
,
0
:
10
]
#print 'random?[-1,-10:]\n', cpu_
c_
out[-1,-10:]
#print 'random?[-1,-10:]\n', cpu_out[-1,-10:]
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg cpu
(C)
'
,
inputs
=
input
)
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg cpu'
,
inputs
=
input
)
if
mode
!=
'FAST_COMPILE'
and
cuda_available
:
if
mode
!=
'FAST_COMPILE'
and
cuda_available
:
print
''
print
''
...
@@ -371,7 +368,6 @@ def test_uniform():
...
@@ -371,7 +368,6 @@ def test_uniform():
for
node
in
f
.
maker
.
env
.
toposort
()])
for
node
in
f
.
maker
.
env
.
toposort
()])
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
gpu_out
=
numpy
.
asarray
(
f
(
*
input
))
gpu_out
=
numpy
.
asarray
(
f
(
*
input
))
#pickle.dump(gpu_out, open('debug_rng_gpu.pkl','w'))
print
'random?[:10]
\n
'
print
'random?[:10]
\n
'
print
gpu_out
[
0
,
0
:
10
]
print
gpu_out
[
0
,
0
:
10
]
...
@@ -379,7 +375,7 @@ def test_uniform():
...
@@ -379,7 +375,7 @@ def test_uniform():
#print 'random?[-1,-10:]\n', gpu_out[-1,-10:]
#print 'random?[-1,-10:]\n', gpu_out[-1,-10:]
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg gpu'
,
inputs
=
input
)
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg gpu'
,
inputs
=
input
)
numpy
.
testing
.
assert_array_almost_equal
(
cpu_
c_
out
,
gpu_out
,
decimal
=
6
)
numpy
.
testing
.
assert_array_almost_equal
(
cpu_out
,
gpu_out
,
decimal
=
6
)
print
''
print
''
print
'ON CPU w Numpy with size=(
%
s):'
%
str
(
size
)
print
'ON CPU w Numpy with size=(
%
s):'
%
str
(
size
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论