Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
52b6a213
提交
52b6a213
authored
10月 29, 2015
作者:
Amjad Almahairi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new test for compatibility
上级
f12dca6f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
1 行删除
+18
-1
multinomial_test_graph.pkl
theano/sandbox/tests/multinomial_test_graph.pkl
+0
-0
test_multinomial.py
theano/sandbox/tests/test_multinomial.py
+18
-1
没有找到文件。
theano/sandbox/tests/multinomial_test_graph.pkl
0 → 100644
浏览文件 @
52b6a213
This source diff could not be displayed because it is too large. You can
view the blob
instead.
theano/sandbox/tests/test_multinomial.py
浏览文件 @
52b6a213
...
@@ -8,7 +8,7 @@ from theano.sandbox import multinomial
...
@@ -8,7 +8,7 @@ from theano.sandbox import multinomial
from
theano.compile.mode
import
get_default_mode
,
predefined_linkers
from
theano.compile.mode
import
get_default_mode
,
predefined_linkers
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
import
theano.tests.unittest_tools
as
utt
import
theano.tests.unittest_tools
as
utt
import
cPickle
def
get_mode
(
gpu
):
def
get_mode
(
gpu
):
mode
=
get_default_mode
()
mode
=
get_default_mode
()
...
@@ -67,6 +67,23 @@ def test_n_samples_2():
...
@@ -67,6 +67,23 @@ def test_n_samples_2():
res
=
f
(
pvals
,
uni
,
i
)
res
=
f
(
pvals
,
uni
,
i
)
assert
res
.
sum
()
==
i
assert
res
.
sum
()
==
i
def
test_n_samples_compatibility
():
"""
This test checks if the new change to MultinomialFromUniform is still compatible
with old interface. Here I will load a graph created (using the old interface) as follows:
RandomStreams = theano.sandbox.rng_mrg.MRG_RandomStreams
th_rng = RandomStreams(12345)
X = T.matrix('X')
pvals = T.exp(X)
pvals = pvals / pvals.sum(axis=1, keepdims=True)
samples = th_rng.multinomial(pvals=pvals)
cPickle.dump([X, samples], open("multinomial_test_graph.pkl", "w"))
"""
X
,
samples
=
cPickle
.
load
(
open
(
"multinomial_test_graph.pkl"
))
f
=
theano
.
function
([
X
],
samples
)
res
=
f
(
numpy
.
random
.
randn
(
20
,
10
))
assert
numpy
.
all
(
res
.
sum
(
axis
=
1
)
==
1
)
def
test_multinomial_0
():
def
test_multinomial_0
():
# This tests the MultinomialFromUniform Op directly, not going through the
# This tests the MultinomialFromUniform Op directly, not going through the
# multinomial() call in GPU random generation.
# multinomial() call in GPU random generation.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论