Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0845a3d6
提交
0845a3d6
authored
2月 21, 2012
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #464 from lamblin/fix_eq_opt_error
Fix max'd error in EquilibriumOptimizer with constant folding
上级
95d19a6a
386b046b
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
12 行删除
+9
-12
opt.py
theano/gof/opt.py
+7
-6
optdb.py
theano/gof/optdb.py
+1
-5
test_opt.py
theano/gof/tests/test_opt.py
+1
-1
没有找到文件。
theano/gof/opt.py
浏览文件 @
0845a3d6
...
@@ -1113,6 +1113,7 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1113,6 +1113,7 @@ class EquilibriumOptimizer(NavigatorOptimizer):
max_use_abort
=
False
max_use_abort
=
False
opt_name
=
None
opt_name
=
None
process_count
=
{}
process_count
=
{}
max_nb_nodes
=
0
while
changed
and
not
max_use_abort
:
while
changed
and
not
max_use_abort
:
changed
=
False
changed
=
False
...
@@ -1130,7 +1131,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1130,7 +1131,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
q
=
deque
(
graph
.
io_toposort
(
env
.
inputs
,
start_from
))
q
=
deque
(
graph
.
io_toposort
(
env
.
inputs
,
start_from
))
max_use
=
len
(
q
)
*
self
.
max_use_ratio
max_nb_nodes
=
max
(
max_nb_nodes
,
len
(
q
))
max_use
=
max_nb_nodes
*
self
.
max_use_ratio
def
importer
(
node
):
def
importer
(
node
):
if
node
is
not
current_node
:
if
node
is
not
current_node
:
q
.
append
(
node
)
q
.
append
(
node
)
...
@@ -1148,15 +1150,14 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1148,15 +1150,14 @@ class EquilibriumOptimizer(NavigatorOptimizer):
current_node
=
node
current_node
=
node
for
lopt
in
self
.
local_optimizers
:
for
lopt
in
self
.
local_optimizers
:
process_count
.
setdefault
(
lopt
,
0
)
process_count
.
setdefault
(
lopt
,
0
)
if
process_count
[
lopt
]
>
max_use
:
max_use_abort
=
True
opt_name
=
(
getattr
(
lopt
,
"name"
,
None
)
or
getattr
(
lopt
,
"__name__"
,
None
)
or
""
)
else
:
lopt_change
=
self
.
process_node
(
env
,
node
,
lopt
)
lopt_change
=
self
.
process_node
(
env
,
node
,
lopt
)
if
lopt_change
:
if
lopt_change
:
process_count
[
lopt
]
+=
1
process_count
[
lopt
]
+=
1
changed
=
True
changed
=
True
if
process_count
[
lopt
]
>
max_use
:
max_use_abort
=
True
opt_name
=
(
getattr
(
lopt
,
"name"
,
None
)
or
getattr
(
lopt
,
"__name__"
,
""
))
if
node
not
in
env
.
nodes
:
if
node
not
in
env
.
nodes
:
break
# go to next node
break
# go to next node
finally
:
finally
:
...
...
theano/gof/optdb.py
浏览文件 @
0845a3d6
...
@@ -15,13 +15,9 @@ AddConfigVar('optdb.position_cutoff',
...
@@ -15,13 +15,9 @@ AddConfigVar('optdb.position_cutoff',
' position of the optimizer where to stop.'
,
' position of the optimizer where to stop.'
,
FloatParam
(
numpy
.
inf
),
FloatParam
(
numpy
.
inf
),
in_c_key
=
False
)
in_c_key
=
False
)
#upgraded to 20 to avoid EquibriumOptimizer error
# to be max'ed out by constant folding (can
# I increase the max ratio only for
# constant folding somehow?
AddConfigVar
(
'optdb.max_use_ratio'
,
AddConfigVar
(
'optdb.max_use_ratio'
,
'A ratio that prevent infinite loop in EquilibriumOptimizer.'
,
'A ratio that prevent infinite loop in EquilibriumOptimizer.'
,
FloatParam
(
20
),
FloatParam
(
5
),
in_c_key
=
False
)
in_c_key
=
False
)
...
...
theano/gof/tests/test_opt.py
浏览文件 @
0845a3d6
...
@@ -406,4 +406,4 @@ class TestEquilibrium(object):
...
@@ -406,4 +406,4 @@ class TestEquilibrium(object):
finally
:
finally
:
_logger
.
setLevel
(
oldlevel
)
_logger
.
setLevel
(
oldlevel
)
print
'after'
,
g
print
'after'
,
g
assert
str
(
g
)
==
'[Op
4
(x, y)]'
assert
str
(
g
)
==
'[Op
1
(x, y)]'
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论