Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cc3cca1f
提交
cc3cca1f
authored
3月 15, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mrg - 80char
上级
7786f27e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
5 行删除
+9
-5
rng_mrg.py
theano/sandbox/rng_mrg.py
+9
-5
没有找到文件。
theano/sandbox/rng_mrg.py
浏览文件 @
cc3cca1f
...
@@ -9,13 +9,14 @@ import sys
...
@@ -9,13 +9,14 @@ import sys
import
numpy
import
numpy
from
theano
import
Op
,
Apply
,
shared
,
config
,
Variable
from
theano
import
Op
,
Apply
,
shared
,
config
,
Variable
from
theano.tensor
import
raw_random
,
TensorType
,
as_tensor_variable
,
get_vector_length
,
cast
,
opt
from
theano.tensor
import
(
raw_random
,
TensorType
,
as_tensor_variable
,
get_vector_length
,
cast
,
opt
)
from
theano.tensor
import
zeros_like
,
sqrt
,
log
,
sin
,
cos
,
join
,
prod
from
theano.tensor
import
zeros_like
,
sqrt
,
log
,
sin
,
cos
,
join
,
prod
from
theano.compile
import
optdb
from
theano.compile
import
optdb
from
theano.gof
import
local_optimizer
from
theano.gof
import
local_optimizer
from
theano.gof.python25
import
all
from
theano.gof.python25
import
all
from
multinomial
import
multinomial
import
multinomial
from
theano.sandbox.cuda
import
cuda_available
,
cuda_enabled
from
theano.sandbox.cuda
import
cuda_available
,
cuda_enabled
if
cuda_available
:
if
cuda_available
:
...
@@ -83,10 +84,12 @@ def mrg_next_value(rstate, new_rstate):
...
@@ -83,10 +84,12 @@ def mrg_next_value(rstate, new_rstate):
x11
,
x12
,
x13
,
x21
,
x22
,
x23
=
rstate
x11
,
x12
,
x13
,
x21
,
x22
,
x23
=
rstate
assert
type
(
x11
)
==
numpy
.
int32
assert
type
(
x11
)
==
numpy
.
int32
i0
,
i7
,
i9
,
i15
,
i16
,
i22
,
i24
=
[
numpy
.
int32
(
i
)
for
i
in
(
0
,
7
,
9
,
15
,
16
,
22
,
24
)]
i0
,
i7
,
i9
,
i15
,
i16
,
i22
,
i24
=
[
numpy
.
int32
(
i
)
for
i
in
(
0
,
7
,
9
,
15
,
16
,
22
,
24
)]
#first component
#first component
y1
=
((
x12
&
MASK12
)
<<
i22
)
+
(
x12
>>
i9
)
+
((
x13
&
MASK13
)
<<
i7
)
+
(
x13
>>
i24
);
y1
=
(((
x12
&
MASK12
)
<<
i22
)
+
(
x12
>>
i9
)
+
((
x13
&
MASK13
)
<<
i7
)
+
(
x13
>>
i24
))
assert
type
(
y1
)
==
numpy
.
int32
assert
type
(
y1
)
==
numpy
.
int32
if
(
y1
<
0
or
y1
>=
M1
):
#must also check overflow
if
(
y1
<
0
or
y1
>=
M1
):
#must also check overflow
...
@@ -724,7 +727,8 @@ class MRG_RandomStreams(object):
...
@@ -724,7 +727,8 @@ class MRG_RandomStreams(object):
else
:
else
:
raise
NotImplementedError
(
"MRG_RandomStreams.binomial with n > 1"
)
raise
NotImplementedError
(
"MRG_RandomStreams.binomial with n > 1"
)
def
multinomial
(
self
,
size
=
None
,
n
=
1
,
pvals
=
None
,
ndim
=
None
,
dtype
=
'int64'
):
def
multinomial
(
self
,
size
=
None
,
n
=
1
,
pvals
=
None
,
ndim
=
None
,
dtype
=
'int64'
,
n_unis
=
None
):
"""
"""
Sample `n` (currently `n` needs to be 1) times from a multinomial
Sample `n` (currently `n` needs to be 1) times from a multinomial
distribution defined by probabilities pvals.
distribution defined by probabilities pvals.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论