Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
871eee1b
提交
871eee1b
authored
4月 03, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix crash for Composite with multiple outputs just introduced and test the flatte.
上级
4f15d801
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
16 行删除
+15
-16
basic.py
theano/scalar/basic.py
+4
-3
test_basic.py
theano/scalar/tests/test_basic.py
+11
-13
没有找到文件。
theano/scalar/basic.py
浏览文件 @
871eee1b
...
@@ -2980,7 +2980,8 @@ class Composite(ScalarOp):
...
@@ -2980,7 +2980,8 @@ class Composite(ScalarOp):
# that will flatten Composite. We don't need to do this
# that will flatten Composite. We don't need to do this
# recusively, as the way the fusion optimizer work, we have
# recusively, as the way the fusion optimizer work, we have
# only 1 new Composite each time at the output.
# only 1 new Composite each time at the output.
if
not
any
([
isinstance
(
var
.
owner
.
op
,
Composite
)
for
var
in
outputs
]):
if
len
(
outputs
)
>
1
or
not
any
([
isinstance
(
var
.
owner
.
op
,
Composite
)
for
var
in
outputs
]):
# No inner Composite
# No inner Composite
inputs
,
outputs
=
gof
.
graph
.
clone
(
inputs
,
outputs
)
inputs
,
outputs
=
gof
.
graph
.
clone
(
inputs
,
outputs
)
else
:
else
:
...
@@ -3004,8 +3005,8 @@ class Composite(ScalarOp):
...
@@ -3004,8 +3005,8 @@ class Composite(ScalarOp):
assert
res
[
0
]
!=
inputs
assert
res
[
0
]
!=
inputs
inputs
,
outputs
=
res
[
0
],
res2
[
1
]
inputs
,
outputs
=
res
[
0
],
res2
[
1
]
# Next assert comment just for speed
# Next assert comment just for speed
assert
not
any
([
isinstance
(
node
.
op
,
Composite
)
for
node
in
#
assert not any([isinstance(node.op, Composite) for node in
theano
.
gof
.
graph
.
ops
(
inputs
,
outputs
)])
#
theano.gof.graph.ops(inputs, outputs)])
self
.
inputs
=
copy
(
inputs
)
self
.
inputs
=
copy
(
inputs
)
self
.
outputs
=
copy
(
outputs
)
self
.
outputs
=
copy
(
outputs
)
...
...
theano/scalar/tests/test_basic.py
浏览文件 @
871eee1b
...
@@ -68,19 +68,17 @@ class test_composite(unittest.TestCase):
...
@@ -68,19 +68,17 @@ class test_composite(unittest.TestCase):
fn
=
gof
.
DualLinker
()
.
accept
(
g
)
.
make_function
()
fn
=
gof
.
DualLinker
()
.
accept
(
g
)
.
make_function
()
assert
fn
(
1.0
,
2.0
)
==
1.5
assert
fn
(
1.0
,
2.0
)
==
1.5
# def test_sin(self):
def
test_flatten
(
self
):
# x = inputs()
#Test that we flatten multiple Composite.
# e = sin(x)
x
,
y
,
z
=
inputs
()
# C = Composite([x], [e])
C
=
Composite
([
x
,
y
],
[
x
+
y
])
# c = C.make_node(x)
CC
=
Composite
([
x
,
y
],
[
C
(
x
*
y
,
y
)])
# # print c.c_code(['x'], ['z'], dict(id = 0))
assert
not
isinstance
(
CC
.
outputs
[
0
]
.
owner
.
op
,
Composite
)
# g = FunctionGraph([x], [c.out])
# fn = gof.DualLinker().accept(g).make_function()
# Test with multiple outputs
# assert fn(0) == 0
CC
=
Composite
([
x
,
y
,
z
],
[
C
(
x
*
y
,
y
),
C
(
x
*
z
,
y
)])
# assert fn(3.14159265358/2) == 1
#We don't flatten that case.
# assert fn(3.14159265358) == 0
assert
isinstance
(
CC
.
outputs
[
0
]
.
owner
.
op
,
Composite
)
# WRITEME: Test for sin, pow, and other scalar ops.
def
test_with_constants
(
self
):
def
test_with_constants
(
self
):
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论