Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4c90eecc
提交
4c90eecc
authored
5月 02, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
7f3e28e4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
22 行删除
+28
-22
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+28
-22
没有找到文件。
theano/sandbox/test_rng_mrg.py
浏览文件 @
4c90eecc
...
@@ -166,7 +166,8 @@ def test_consistency_cpu_parallel():
...
@@ -166,7 +166,8 @@ def test_consistency_cpu_parallel():
rstate
=
theano
.
shared
(
rstate
)
rstate
=
theano
.
shared
(
rstate
)
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
config
.
floatX
,
size
=
(
n_substreams
,))
dtype
=
config
.
floatX
,
size
=
(
n_substreams
,))
# Not really necessary, just mimicking
# Not really necessary, just mimicking
# rng_mrg.MRG_RandomStreams' behavior
# rng_mrg.MRG_RandomStreams' behavior
sample
.
rstate
=
rstate
sample
.
rstate
=
rstate
...
@@ -219,7 +220,8 @@ def test_consistency_GPU_serial():
...
@@ -219,7 +220,8 @@ def test_consistency_GPU_serial():
rstate
=
float32_shared_constructor
(
tmp_float_buf
)
rstate
=
float32_shared_constructor
(
tmp_float_buf
)
new_rstate
,
sample
=
rng_mrg
.
GPU_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
rng_mrg
.
GPU_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
'float32'
,
size
=
(
1
,))
dtype
=
'float32'
,
size
=
(
1
,))
rstate
.
default_update
=
new_rstate
rstate
.
default_update
=
new_rstate
# Not really necessary, just mimicking
# Not really necessary, just mimicking
...
@@ -278,7 +280,8 @@ def test_consistency_GPU_parallel():
...
@@ -278,7 +280,8 @@ def test_consistency_GPU_parallel():
rstate
=
float32_shared_constructor
(
tmp_float_buf
)
rstate
=
float32_shared_constructor
(
tmp_float_buf
)
new_rstate
,
sample
=
rng_mrg
.
GPU_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
rng_mrg
.
GPU_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
'float32'
,
size
=
(
n_substreams
,))
dtype
=
'float32'
,
size
=
(
n_substreams
,))
rstate
.
default_update
=
new_rstate
rstate
.
default_update
=
new_rstate
# Not really necessary, just mimicking
# Not really necessary, just mimicking
...
@@ -381,7 +384,8 @@ def test_consistency_GPUA_parallel():
...
@@ -381,7 +384,8 @@ def test_consistency_GPUA_parallel():
rstate
=
gpuarray_shared_constructor
(
rstate
)
rstate
=
gpuarray_shared_constructor
(
rstate
)
new_rstate
,
sample
=
rng_mrg
.
GPUA_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
rng_mrg
.
GPUA_mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
'float32'
,
size
=
(
n_substreams
,))
dtype
=
'float32'
,
size
=
(
n_substreams
,))
rstate
.
default_update
=
new_rstate
rstate
.
default_update
=
new_rstate
# Not really necessary, just mimicking
# Not really necessary, just mimicking
...
@@ -452,7 +456,7 @@ def basictest(f, steps, sample_size, prefix="", allow_01=False, inputs=None,
...
@@ -452,7 +456,7 @@ def basictest(f, steps, sample_size, prefix="", allow_01=False, inputs=None,
#print prefix, 'std', std
#print prefix, 'std', std
if
target_std
is
not
None
:
if
target_std
is
not
None
:
assert
abs
(
std
-
target_std
)
<
std_tol
*
(
1
+
abs
(
target_std
)),
(
assert
abs
(
std
-
target_std
)
<
std_tol
*
(
1
+
abs
(
target_std
)),
(
'bad std?
%
f
%
f
%
f'
%
(
std
,
target_std
,
std_tol
))
'bad std?
%
f
%
f
%
f'
%
(
std
,
target_std
,
std_tol
))
#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
...
@@ -522,8 +526,8 @@ def test_uniform():
...
@@ -522,8 +526,8 @@ def test_uniform():
# well, it's really that this test w GPU doesn't make sense otw
# well, it's really that this test w GPU doesn't make sense otw
assert
u
.
dtype
==
'float32'
assert
u
.
dtype
==
'float32'
f
=
theano
.
function
(
var_input
,
theano
.
Out
(
f
=
theano
.
function
(
var_input
,
theano
.
Out
(
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
borrow
=
True
),
mode
=
mode_with_gpu
)
borrow
=
True
),
mode
=
mode_with_gpu
)
assert
any
([
isinstance
(
node
.
op
,
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
rng_mrg
.
GPU_mrg_uniform
)
theano
.
sandbox
.
rng_mrg
.
GPU_mrg_uniform
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
...
@@ -613,8 +617,8 @@ def test_binomial():
...
@@ -613,8 +617,8 @@ def test_binomial():
#well, it's really that this test w GPU doesn't make sense otw
#well, it's really that this test w GPU doesn't make sense otw
assert
u
.
dtype
==
'float32'
assert
u
.
dtype
==
'float32'
f
=
theano
.
function
(
var_input
,
theano
.
Out
(
f
=
theano
.
function
(
var_input
,
theano
.
Out
(
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
u
),
borrow
=
True
),
mode
=
mode_with_gpu
)
borrow
=
True
),
mode
=
mode_with_gpu
)
#theano.printing.debugprint(f)
#theano.printing.debugprint(f)
gpu_out
=
numpy
.
asarray
(
f
(
*
input
))
gpu_out
=
numpy
.
asarray
(
f
(
*
input
))
#print 'random?[:10]\n', gpu_out[0, 0:10]
#print 'random?[:10]\n', gpu_out[0, 0:10]
...
@@ -799,9 +803,9 @@ def test_multinomial():
...
@@ -799,9 +803,9 @@ def test_multinomial():
#well, it's really that this test w GPU doesn't make sense otw
#well, it's really that this test w GPU doesn't make sense otw
assert
n
.
dtype
==
'float32'
assert
n
.
dtype
==
'float32'
f
=
theano
.
function
(
f
=
theano
.
function
(
[],
[],
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
n
),
theano
.
sandbox
.
cuda
.
basic_ops
.
gpu_from_host
(
n
),
mode
=
mode_
.
including
(
'gpu'
))
mode
=
mode_
.
including
(
'gpu'
))
#theano.printing.debugprint(f)
#theano.printing.debugprint(f)
gpu_out
=
f
()
gpu_out
=
f
()
...
@@ -883,24 +887,26 @@ def test_multMatVect():
...
@@ -883,24 +887,26 @@ def test_multMatVect():
A2
=
tensor
.
lmatrix
(
'A2'
)
A2
=
tensor
.
lmatrix
(
'A2'
)
s2
=
tensor
.
ivector
(
's2'
)
s2
=
tensor
.
ivector
(
's2'
)
m2
=
tensor
.
iscalar
(
'm2'
)
m2
=
tensor
.
iscalar
(
'm2'
)
g0
=
rng_mrg
.
DotModulo
()(
A1
,
s1
,
m1
,
A2
,
s2
,
m2
)
g0
=
rng_mrg
.
DotModulo
()(
A1
,
s1
,
m1
,
A2
,
s2
,
m2
)
f0
=
theano
.
function
([
A1
,
s1
,
m1
,
A2
,
s2
,
m2
],
g0
)
f0
=
theano
.
function
([
A1
,
s1
,
m1
,
A2
,
s2
,
m2
],
g0
)
A1
=
numpy
.
random
.
randint
(
0
,
numpy
.
iinfo
(
numpy
.
int32
)
.
max
,
(
3
,
3
))
.
astype
(
'int64'
)
i32max
=
numpy
.
iinfo
(
numpy
.
int32
)
.
max
s1
=
numpy
.
random
.
randint
(
0
,
numpy
.
iinfo
(
numpy
.
int32
)
.
max
,
3
)
.
astype
(
'int32'
)
m1
=
numpy
.
asarray
(
numpy
.
random
.
randint
(
numpy
.
iinfo
(
numpy
.
int32
)
.
max
),
dtype
=
"int32"
)
A1
=
numpy
.
random
.
randint
(
0
,
i32max
,
(
3
,
3
))
.
astype
(
'int64'
)
A2
=
numpy
.
random
.
randint
(
0
,
numpy
.
iinfo
(
numpy
.
int32
)
.
max
,
(
3
,
3
))
.
astype
(
'int64'
)
s1
=
numpy
.
random
.
randint
(
0
,
i32max
,
3
)
.
astype
(
'int32'
)
s2
=
numpy
.
random
.
randint
(
0
,
numpy
.
iinfo
(
numpy
.
int32
)
.
max
,
3
)
.
astype
(
'int32'
)
m1
=
numpy
.
asarray
(
numpy
.
random
.
randint
(
i32max
),
dtype
=
"int32"
)
m2
=
numpy
.
asarray
(
numpy
.
random
.
randint
(
numpy
.
iinfo
(
numpy
.
int32
)
.
max
),
dtype
=
"int32"
)
A2
=
numpy
.
random
.
randint
(
0
,
i32max
,
(
3
,
3
))
.
astype
(
'int64'
)
s2
=
numpy
.
random
.
randint
(
0
,
i32max
,
3
)
.
astype
(
'int32'
)
m2
=
numpy
.
asarray
(
numpy
.
random
.
randint
(
i32max
),
dtype
=
"int32"
)
f0
.
input_storage
[
0
]
.
storage
[
0
]
=
A1
f0
.
input_storage
[
0
]
.
storage
[
0
]
=
A1
f0
.
input_storage
[
1
]
.
storage
[
0
]
=
s1
f0
.
input_storage
[
1
]
.
storage
[
0
]
=
s1
f0
.
input_storage
[
2
]
.
storage
[
0
]
=
m1
f0
.
input_storage
[
2
]
.
storage
[
0
]
=
m1
f0
.
input_storage
[
3
]
.
storage
[
0
]
=
A2
f0
.
input_storage
[
3
]
.
storage
[
0
]
=
A2
f0
.
input_storage
[
4
]
.
storage
[
0
]
=
s2
f0
.
input_storage
[
4
]
.
storage
[
0
]
=
s2
f0
.
input_storage
[
5
]
.
storage
[
0
]
=
m2
f0
.
input_storage
[
5
]
.
storage
[
0
]
=
m2
r_a1
=
rng_mrg
.
matVecModM
(
A1
,
s1
,
m1
)
r_a1
=
rng_mrg
.
matVecModM
(
A1
,
s1
,
m1
)
r_a2
=
rng_mrg
.
matVecModM
(
A2
,
s2
,
m2
)
r_a2
=
rng_mrg
.
matVecModM
(
A2
,
s2
,
m2
)
f0
.
fn
()
f0
.
fn
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论