Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fd29e66f
提交
fd29e66f
authored
8月 24, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a theano flags to print the time inside each optimizer into a SeqOptimizer
上级
f552b784
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
1 行删除
+24
-1
opt.py
theano/gof/opt.py
+24
-1
没有找到文件。
theano/gof/opt.py
浏览文件 @
fd29e66f
...
...
@@ -4,7 +4,7 @@ amount of useful generic optimization tools.
"""
import
sys
,
logging
import
sys
,
logging
,
time
import
graph
from
env
import
InconsistencyError
import
utils
...
...
@@ -13,12 +13,17 @@ import toolbox
import
op
from
copy
import
copy
from
theano.gof.python25
import
any
,
all
from
theano.configparser
import
AddConfigVar
,
BoolParam
,
config
#if sys.version_info[:2] >= (2,5):
# from collections import defaultdict
_logger
=
logging
.
getLogger
(
'theano.gof.opt'
)
AddConfigVar
(
'time_seq_optimizer'
,
"Should SeqOptimizer print the time taked by each of its optimizer"
,
BoolParam
(
False
))
from
theano.gof
import
deque
import
destroyhandler
as
dh
import
traceback
...
...
@@ -126,9 +131,13 @@ class SeqOptimizer(Optimizer, list):
"""WRITEME
Applies each L{Optimizer} in self in turn.
"""
l
=
[]
nb_node_before
=
len
(
env
.
nodes
)
for
optimizer
in
self
:
try
:
t0
=
time
.
time
()
optimizer
.
optimize
(
env
)
l
.
append
(
float
(
time
.
time
()
-
t0
))
except
AssertionError
:
# do not catch Assertion failures
raise
except
Exception
,
e
:
...
...
@@ -137,6 +146,20 @@ class SeqOptimizer(Optimizer, list):
continue
else
:
raise
if
config
.
time_seq_optimizer
:
print
"SeqOptimizer"
,
if
hasattr
(
self
,
"name"
):
print
self
.
name
,
elif
hasattr
(
self
,
"__name__"
):
print
self
.
__name__
,
print
" time
%.3
fs for
%
d/
%
d nodes before/after optimization"
%
(
sum
(
l
),
nb_node_before
,
len
(
env
.
nodes
))
ll
=
[(
opt
.
__name__
if
hasattr
(
opt
,
"__name__"
)
else
opt
.
name
,
opt
.
__class__
.
__name__
)
for
opt
in
self
]
lll
=
zip
(
l
,
ll
)
def
cmp
(
a
,
b
):
if
a
[
0
]
==
b
[
0
]:
return
0
if
a
[
0
]
<
b
[
0
]:
return
-
1
return
1
lll
.
sort
(
cmp
)
print
lll
def
__eq__
(
self
,
other
):
#added to override the list's __eq__ implementation
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论