Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1c11f7f9
提交
1c11f7f9
authored
1月 25, 2011
作者:
desjagui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MRG_RandomStreams unittest was not comparing the results of C, Python and GPU
random numbers properly. This was hiding a GPU bug. Fix is in progress.
上级
37b10520
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
8 行删除
+42
-8
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+42
-8
没有找到文件。
theano/sandbox/test_rng_mrg.py
浏览文件 @
1c11f7f9
...
@@ -323,6 +323,9 @@ def test_uniform():
...
@@ -323,6 +323,9 @@ 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
...
@@ -336,8 +339,9 @@ def test_uniform():
...
@@ -336,8 +339,9 @@ 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 ####
print
''
print
''
print
'ON CPU with size=(
%
s):'
%
str
(
size
)
print
'ON CPU
(C)
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
)
...
@@ -345,10 +349,32 @@ def test_uniform():
...
@@ -345,10 +349,32 @@ 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
)
out
=
f
(
*
input
)
cpu_c_out
=
f
(
*
input
)
print
'random?[:10]
\n
'
,
out
[
0
,
0
:
10
]
pickle
.
dump
(
cpu_c_out
,
open
(
'/u/desjagui/temp/debug_rng_cpu_c.pkl'
,
'w'
))
#print 'random?[-1,-10:]\n', out[-1,-10:]
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg cpu'
,
inputs
=
input
)
print
'random?[:10]
\n
'
print
cpu_c_out
[
0
,
0
:
10
]
print
cpu_c_out
[
-
1
,
0
:
10
]
#print 'random?[-1,-10:]\n', cpu_c_out[-1,-10:]
basictest
(
f
,
steps
,
sample_size
,
prefix
=
'mrg cpu (C)'
,
inputs
=
input
)
#### TEST CPU (PYTHON) IMPLEMENTATION ####
print
''
print
'ON CPU (Python) with size=(
%
s):'
%
str
(
size
)
R
=
MRG_RandomStreams
(
234
,
use_cuda
=
False
)
u
=
R
.
uniform
(
size
=
size
)
f
=
theano
.
function
(
var_input
,
u
,
mode
=
theano
.
Mode
(
linker
=
'py'
))
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
mrg_uniform
)
for
node
in
f
.
maker
.
env
.
toposort
()])
theano
.
printing
.
debugprint
(
f
)
cpu_py_out
=
f
(
*
input
)
pickle
.
dump
(
cpu_py_out
,
open
(
'/u/desjagui/temp/debug_rng_cpu_py.pkl'
,
'w'
))
print
'random?[:10]
\n
'
print
cpu_py_out
[
0
,
0
:
10
]
print
cpu_py_out
[
-
1
,
0
:
10
]
#print 'random?[-1,-10:]\n', cpu_py_out[-1,-10:]
#basictest(f, steps, sample_size, prefix='mrg cpu (Python)', inputs=input)
if
mode
!=
'FAST_COMPILE'
and
cuda_available
:
if
mode
!=
'FAST_COMPILE'
and
cuda_available
:
print
''
print
''
...
@@ -362,11 +388,19 @@ def test_uniform():
...
@@ -362,11 +388,19 @@ def test_uniform():
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
GPU_mrg_uniform
)
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
GPU_mrg_uniform
)
for
node
in
f
.
maker
.
env
.
toposort
()])
for
node
in
f
.
maker
.
env
.
toposort
()])
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
out
=
numpy
.
asarray
(
f
(
*
input
))
gpu_out
=
numpy
.
asarray
(
f
(
*
input
))
print
'random?[:10]
\n
'
,
out
[
0
,
0
:
10
]
pickle
.
dump
(
gpu_out
,
open
(
'/u/desjagui/temp/debug_rng_gpu.pkl'
,
'w'
))
#print 'random?[-1,-10:]\n', out[-1,-10:]
print
'random?[:10]
\n
'
print
gpu_out
[
0
,
0
:
10
]
print
gpu_out
[
-
1
,
0
:
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
,
cpu_py_out
)
numpy
.
testing
.
assert_array_almost_equal
(
cpu_c_out
,
gpu_out
)
print
''
print
''
print
'ON CPU w Numpy with size=(
%
s):'
%
str
(
size
)
print
'ON CPU w Numpy with size=(
%
s):'
%
str
(
size
)
RR
=
theano
.
tensor
.
shared_randomstreams
.
RandomStreams
(
234
)
RR
=
theano
.
tensor
.
shared_randomstreams
.
RandomStreams
(
234
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论