Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
399cff79
提交
399cff79
authored
3月 09, 2009
作者:
james@X40
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes to make RandomFunction work on 32bit
上级
e68f24dc
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
8 行增加
和
6 行删除
+8
-6
raw_random.py
theano/tensor/raw_random.py
+1
-1
rmodule.py
theano/tensor/rmodule.py
+4
-2
test_rmodule.py
theano/tensor/tests/test_rmodule.py
+3
-3
没有找到文件。
theano/tensor/raw_random.py
浏览文件 @
399cff79
...
@@ -118,7 +118,7 @@ class RandomFunction(gof.Op):
...
@@ -118,7 +118,7 @@ class RandomFunction(gof.Op):
shape
=
tensor
.
as_tensor
(
shape
,
ndim
=
1
)
shape
=
tensor
.
as_tensor
(
shape
,
ndim
=
1
)
#print 'SHAPE TYPE', shape.type, tensor.lvector
#print 'SHAPE TYPE', shape.type, tensor.lvector
assert
shape
.
type
.
ndim
==
1
assert
shape
.
type
.
ndim
==
1
assert
shape
.
type
.
dtype
==
'int64'
assert
(
shape
.
type
.
dtype
==
'int64'
)
or
(
shape
.
type
.
dtype
==
'int32'
)
if
not
isinstance
(
r
.
type
,
RandomStateType
):
if
not
isinstance
(
r
.
type
,
RandomStateType
):
print
>>
sys
.
stderr
,
'WARNING: RandomState instances should be in RandomStateType'
print
>>
sys
.
stderr
,
'WARNING: RandomState instances should be in RandomStateType'
if
0
:
if
0
:
...
...
theano/tensor/rmodule.py
浏览文件 @
399cff79
...
@@ -128,9 +128,11 @@ class RandomStreamsInstance(object):
...
@@ -128,9 +128,11 @@ class RandomStreamsInstance(object):
old_r_seed
=
seedgen
.
randint
(
2
**
30
)
old_r_seed
=
seedgen
.
randint
(
2
**
30
)
old_r_container
=
self
.
memo
[
old_r
]
.
value
old_r_container
=
self
.
memo
[
old_r
]
.
value
if
old_r_container
.
value
is
None
:
if
old_r_container
.
value
is
None
:
old_r_container
.
value
=
numpy
.
random
.
RandomState
(
old_r_seed
)
#the cast to int here makes it work on 32bit machines, not sure why
old_r_container
.
value
=
numpy
.
random
.
RandomState
(
int
(
old_r_seed
))
else
:
else
:
old_r_container
.
value
.
seed
(
old_r_seed
)
#the cast to int here makes it work on 32bit machines, not sure why
old_r_container
.
value
.
seed
(
int
(
old_r_seed
))
def
__getitem__
(
self
,
item
):
def
__getitem__
(
self
,
item
):
"""Retrieve the numpy RandomState instance associated with a particular stream
"""Retrieve the numpy RandomState instance associated with a particular stream
...
...
theano/tensor/tests/test_rmodule.py
浏览文件 @
399cff79
...
@@ -25,7 +25,7 @@ class T_RandomStreams(unittest.TestCase):
...
@@ -25,7 +25,7 @@ class T_RandomStreams(unittest.TestCase):
gn_val0
=
made
.
gn
()
gn_val0
=
made
.
gn
()
rng_seed
=
numpy
.
random
.
RandomState
(
234
)
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
234
)
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
rng_seed
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#int() is for 32bit
#print fn_val0
#print fn_val0
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
...
@@ -46,7 +46,7 @@ class T_RandomStreams(unittest.TestCase):
...
@@ -46,7 +46,7 @@ class T_RandomStreams(unittest.TestCase):
fn_val1
=
made
.
fn
()
fn_val1
=
made
.
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
888
)
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
888
)
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
rng_seed
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#int() is for 32bit
#print fn_val0
#print fn_val0
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
...
@@ -69,7 +69,7 @@ class T_RandomStreams(unittest.TestCase):
...
@@ -69,7 +69,7 @@ class T_RandomStreams(unittest.TestCase):
fn_val1
=
made
.
fn
()
fn_val1
=
made
.
fn
()
rng_seed
=
numpy
.
random
.
RandomState
(
888
)
.
randint
(
2
**
30
)
rng_seed
=
numpy
.
random
.
RandomState
(
888
)
.
randint
(
2
**
30
)
rng
=
numpy
.
random
.
RandomState
(
rng_seed
)
rng
=
numpy
.
random
.
RandomState
(
int
(
rng_seed
))
#int() is for 32bit
#print fn_val0
#print fn_val0
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
numpy_val0
=
rng
.
uniform
(
size
=
(
2
,
2
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论