Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0f369fc5
提交
0f369fc5
authored
3月 31, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added unittest to trigger canonizer bug: tensor/tests/test_opt.py:test_add_canonizer_problem0
上级
2445d46f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
2 行删除
+21
-2
opt.py
theano/tensor/opt.py
+12
-2
test_opt.py
theano/tensor/tests/test_opt.py
+9
-0
没有找到文件。
theano/tensor/opt.py
浏览文件 @
0f369fc5
...
@@ -16,6 +16,8 @@ import itertools
...
@@ -16,6 +16,8 @@ import itertools
import
sys
import
sys
from
..
import
compile
#to register the optimizer built by this file
from
..
import
compile
#to register the optimizer built by this file
from
..compile.debugmode
import
_debugprint
# Utilities
# Utilities
...
@@ -669,11 +671,13 @@ class Canonizer(gof.LocalOptimizer):
...
@@ -669,11 +671,13 @@ class Canonizer(gof.LocalOptimizer):
def
transform
(
self
,
node
):
def
transform
(
self
,
node
):
op
=
node
.
op
op
=
node
.
op
inputs
=
node
.
inputs
out
=
node
.
outputs
[
0
]
if
op
not
in
[
self
.
main
,
self
.
inverse
,
self
.
reciprocal
]:
if
op
not
in
[
self
.
main
,
self
.
inverse
,
self
.
reciprocal
]:
return
False
return
False
inputs
=
node
.
inputs
out
=
node
.
outputs
[
0
]
assert
len
(
node
.
outputs
)
==
1
# I'm not sure if this is actually needed but the following
# I'm not sure if this is actually needed but the following
# block of code puts into "reorg" whether or not we are going
# block of code puts into "reorg" whether or not we are going
# to change the structure of the graph. For example if we have
# to change the structure of the graph. For example if we have
...
@@ -714,6 +718,12 @@ class Canonizer(gof.LocalOptimizer):
...
@@ -714,6 +718,12 @@ class Canonizer(gof.LocalOptimizer):
if
new
.
type
.
broadcastable
!=
out
.
type
.
broadcastable
:
if
new
.
type
.
broadcastable
!=
out
.
type
.
broadcastable
:
new
=
T
.
fill
(
out
,
new
)
new
=
T
.
fill
(
out
,
new
)
if
0
:
print
'BEFORE'
_debugprint
(
out
,
' '
,
depth
=
4
)
print
'AFTER'
_debugprint
(
new
,
' '
,
depth
=
4
)
# if our if's above worked, this should be true. OTW investigate.
# if our if's above worked, this should be true. OTW investigate.
if
new
.
type
!=
out
.
type
:
if
new
.
type
!=
out
.
type
:
print
>>
sys
.
stderr
,
'CANONIZE FAILED: new, out = '
,
new
,
','
,
out
,
'types'
,
new
.
type
,
','
,
out
.
type
print
>>
sys
.
stderr
,
'CANONIZE FAILED: new, out = '
,
new
,
','
,
out
,
'types'
,
new
.
type
,
','
,
out
.
type
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
0f369fc5
...
@@ -62,6 +62,15 @@ class test_dimshuffle_lift(unittest.TestCase):
...
@@ -62,6 +62,15 @@ class test_dimshuffle_lift(unittest.TestCase):
self
.
failUnless
(
str
(
g
)
==
"[add(add(InplaceDimShuffle{x,x,0}(x), InplaceDimShuffle{x,0,1}(y)), z)]"
,
str
(
g
))
self
.
failUnless
(
str
(
g
)
==
"[add(add(InplaceDimShuffle{x,x,0}(x), InplaceDimShuffle{x,0,1}(y)), z)]"
,
str
(
g
))
def
test_add_canonizer_problem0
():
#observed in a real graph
n_segments
=
10
label
=
lscalar
(
'label'
)
segment_labels
=
label
+
numpy
.
asarray
([
0
]
*
n_segments
,
dtype
=
'int64'
)
r
=
segment_labels
*
5
f
=
function
([
label
],
r
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论