Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9b635db7
提交
9b635db7
authored
7月 09, 2015
作者:
ChienliMa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add other test case
上级
12b09e99
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
2 行删除
+32
-2
test_builders.py
theano/compile/tests/test_builders.py
+32
-2
没有找到文件。
theano/compile/tests/test_builders.py
浏览文件 @
9b635db7
...
@@ -7,6 +7,7 @@ from theano.compile import function
...
@@ -7,6 +7,7 @@ from theano.compile import function
from
theano
import
tensor
from
theano
import
tensor
from
theano
import
tensor
as
T
from
theano
import
tensor
as
T
from
theano.tensor.shared_randomstreams
import
RandomStreams
from
theano.compile.builders
import
OpFromGraph
from
theano.compile.builders
import
OpFromGraph
...
@@ -109,17 +110,46 @@ class T_OpFromGraph(unittest.TestCase):
...
@@ -109,17 +110,46 @@ class T_OpFromGraph(unittest.TestCase):
fn
(
xv
,
yv
,
zv
))
fn
(
xv
,
yv
,
zv
))
def
test_connection_pattern
(
self
):
def
test_connection_pattern
(
self
):
# Basic case
x
,
y
,
z
=
T
.
matrices
(
'xyz'
)
x
,
y
,
z
=
T
.
matrices
(
'xyz'
)
out1
=
x
*
y
out1
=
x
*
y
out2
=
y
*
z
out2
=
y
*
z
op
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
],
mode
=
'FAST_RUN'
)
op
1
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
],
mode
=
'FAST_RUN'
)
results
=
op
.
connection_pattern
(
None
)
results
=
op
1
.
connection_pattern
(
None
)
expect_result
=
[[
True
,
False
],
expect_result
=
[[
True
,
False
],
[
True
,
True
],
[
True
,
True
],
[
False
,
True
]]
[
False
,
True
]]
assert
results
==
expect_result
assert
results
==
expect_result
# Graph with ops that don't have a 'full' connection pattern
# and with ops that have multiple outputs
m
,
n
,
p
,
q
=
T
.
matrices
(
'mnpq'
)
o1
,
o2
=
op1
(
m
,
n
,
p
)
out1
,
out2
=
op1
(
o1
,
q
,
o2
)
op2
=
OpFromGraph
([
m
,
n
,
p
,
q
],
[
out1
,
out2
],
mode
=
'FAST_RUN'
)
results
=
op2
.
connection_pattern
(
None
)
expect_result
=
[[
True
,
False
],
[
True
,
True
],
[
False
,
True
],
[
True
,
True
]]
assert
results
==
expect_result
# Inner graph where some computation doesn't rely on explicit inputs
srng
=
RandomStreams
(
seed
=
234
)
rv_u
=
srng
.
uniform
((
2
,
2
))
x
,
y
=
T
.
matrices
(
'xy'
)
out1
=
x
+
rv_u
out2
=
y
+
3
out3
=
3
+
rv_u
op3
=
OpFromGraph
([
x
,
y
],
[
out1
,
out2
,
out3
],
mode
=
'FAST_RUN'
)
results
=
op2
.
connection_pattern
(
None
)
expect_result
=
[[
True
,
False
,
False
],
[
False
,
True
,
False
]]
assert
results
==
expect_result
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论