Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d97431c4
提交
d97431c4
authored
9月 19, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #46 from jaberg/curand
adding CURAND_RandomStreams with support for uniform and normal
上级
95778c8f
885142fc
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
92 行增加
和
0 行删除
+92
-0
__init__.py
theano/sandbox/cuda/__init__.py
+1
-0
rng_curand.py
theano/sandbox/cuda/rng_curand.py
+0
-0
test_rng_curand.py
theano/sandbox/cuda/tests/test_rng_curand.py
+91
-0
没有找到文件。
theano/sandbox/cuda/__init__.py
浏览文件 @
d97431c4
...
@@ -170,6 +170,7 @@ if cuda_available:
...
@@ -170,6 +170,7 @@ if cuda_available:
from
basic_ops
import
host_from_gpu
,
gpu_from_host
,
as_cuda_array
from
basic_ops
import
host_from_gpu
,
gpu_from_host
,
as_cuda_array
import
opt
import
opt
import
cuda_ndarray
import
cuda_ndarray
from
rng_curand
import
CURAND_RandomStreams
def
use
(
device
,
def
use
(
device
,
...
...
theano/sandbox/cuda/rng_curand.py
0 → 100644
浏览文件 @
d97431c4
差异被折叠。
点击展开。
theano/sandbox/cuda/tests/test_rng_curand.py
0 → 100644
浏览文件 @
d97431c4
import
numpy
import
theano
from
theano.sandbox.cuda.rng_curand
import
CURAND_RandomStreams
from
theano.sandbox.rng_mrg
import
MRG_RandomStreams
def
test_uniform_basic
():
rng
=
CURAND_RandomStreams
(
234
)
u0
=
rng
.
uniform
((
10
,
10
))
u1
=
rng
.
uniform
((
10
,
10
))
f0
=
theano
.
function
([],
u0
)
f1
=
theano
.
function
([],
u1
)
v0list
=
[
f0
()
for
i
in
range
(
3
)]
v1list
=
[
f1
()
for
i
in
range
(
3
)]
#print v0list
#print v1list
# assert that elements are different in a few ways
assert
numpy
.
all
(
v0list
[
0
]
!=
v0list
[
1
])
assert
numpy
.
all
(
v1list
[
0
]
!=
v1list
[
1
])
assert
numpy
.
all
(
v0list
[
0
]
!=
v1list
[
0
])
for
v
in
v0list
:
assert
v
.
shape
==
(
10
,
10
)
assert
v
.
min
()
>=
0
assert
v
.
max
()
<=
1
assert
v
.
min
()
<
v
.
max
()
assert
.
25
<=
v
.
mean
()
<=
.
75
def
test_normal_basic
():
rng
=
CURAND_RandomStreams
(
234
)
u0
=
rng
.
normal
((
10
,
10
))
u1
=
rng
.
normal
((
10
,
10
))
f0
=
theano
.
function
([],
u0
)
f1
=
theano
.
function
([],
u1
)
v0list
=
[
f0
()
for
i
in
range
(
3
)]
v1list
=
[
f1
()
for
i
in
range
(
3
)]
#print v0list
#print v1list
# assert that elements are different in a few ways
assert
numpy
.
all
(
v0list
[
0
]
!=
v0list
[
1
])
assert
numpy
.
all
(
v1list
[
0
]
!=
v1list
[
1
])
assert
numpy
.
all
(
v0list
[
0
]
!=
v1list
[
0
])
for
v
in
v0list
:
assert
v
.
shape
==
(
10
,
10
)
assert
v
.
min
()
<
v
.
max
()
assert
-.
5
<=
v
.
mean
()
<=
.
5
def
compare_speed
():
# To run this speed comparison
# cd <directory of this file>
# THEANO_FLAGS=device=gpu \
# python -c 'import test_rng_curand; test_rng_curand.compare_speed()'
mrg
=
MRG_RandomStreams
()
crn
=
CURAND_RandomStreams
(
234
)
N
=
1000
*
100
dest
=
theano
.
shared
(
numpy
.
zeros
(
N
,
dtype
=
theano
.
config
.
floatX
))
mrg_u
=
theano
.
function
([],
[],
updates
=
{
dest
:
mrg
.
uniform
((
N
,))},
profile
=
'mrg uniform'
)
crn_u
=
theano
.
function
([],
[],
updates
=
{
dest
:
crn
.
uniform
((
N
,))},
profile
=
'crn uniform'
)
mrg_n
=
theano
.
function
([],
[],
updates
=
{
dest
:
mrg
.
normal
((
N
,))},
profile
=
'mrg normal'
)
crn_n
=
theano
.
function
([],
[],
updates
=
{
dest
:
crn
.
normal
((
N
,))},
profile
=
'crn normal'
)
for
f
in
mrg_u
,
crn_u
,
mrg_n
,
crn_n
:
# don't time the first call, it has some startup cost
print
'DEBUGPRINT'
print
'----------'
theano
.
printing
.
debugprint
(
f
)
for
i
in
range
(
100
):
for
f
in
mrg_u
,
crn_u
,
mrg_n
,
crn_n
:
# don't time the first call, it has some startup cost
f
.
fn
.
time_thunks
=
(
i
>
0
)
f
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论