Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
f8d6d99d
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f8d6d99d
编写于
8月 05, 2020
作者:
A
A. Unique TensorFlower
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update orbit.Controller: do not write training summary when input summary_dir is None.
PiperOrigin-RevId: 325115012
上级
b3677ae2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
7 deletion
+57
-7
official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py
...n/image_classification/resnet/resnet_ctl_imagenet_main.py
+1
-0
orbit/controller.py
orbit/controller.py
+4
-6
orbit/controller_test.py
orbit/controller_test.py
+52
-1
未找到文件。
official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py
浏览文件 @
f8d6d99d
...
...
@@ -167,6 +167,7 @@ def run(flags_obj):
steps_per_loop
=
steps_per_loop
,
checkpoint_manager
=
checkpoint_manager
,
summary_interval
=
summary_interval
,
summary_dir
=
flags_obj
.
model_dir
,
eval_summary_dir
=
os
.
path
.
join
(
flags_obj
.
model_dir
,
'eval'
))
time_callback
.
on_train_begin
()
...
...
orbit/controller.py
浏览文件 @
f8d6d99d
...
...
@@ -71,9 +71,11 @@ class Controller:
`trainer.train` function will always be enabled. If set, the value
should be divisible by steps_per_loop.
summary_dir: The directory to restore and write checkpoints and summaries.
If None, it will be set to `checkpoint_manager.directory`.
For example, You can set it to `checkpoint_manager.directory`.
If None, it will not write training summarizes.
eval_summary_dir: The directory to write eval summaries. If None, it will
be set to `summary_dir`.
be set to `summary_dir`. If both `summary_dir` and `eval_summary_dir`
are None, it will not write evaluation summarizes.
Raises:
ValueError: If both `trainer` and `evaluator` are None.
...
...
@@ -108,9 +110,6 @@ class Controller:
self
.
global_step
=
global_step
self
.
checkpoint_manager
=
checkpoint_manager
if
summary_dir
is
None
and
checkpoint_manager
:
summary_dir
=
checkpoint_manager
.
directory
if
self
.
trainer
is
not
None
:
self
.
step_timer
=
None
self
.
steps_per_loop
=
steps_per_loop
...
...
@@ -118,7 +117,6 @@ class Controller:
self
.
summary_manager
=
utils
.
SummaryManager
(
summary_dir
,
tf
.
summary
.
scalar
,
global_step
=
self
.
global_step
)
eval_summary_writer
=
None
if
self
.
evaluator
is
not
None
:
eval_summary_dir
=
eval_summary_dir
or
summary_dir
if
eval_summary_dir
==
summary_dir
and
self
.
trainer
is
not
None
:
...
...
orbit/controller_test.py
浏览文件 @
f8d6d99d
...
...
@@ -294,6 +294,56 @@ class ControllerTest(tf.test.TestCase, parameterized.TestCase):
train_steps
=
10
,
eval_steps
=
2
,
eval_interval
=
6
)
self
.
assertEqual
(
test_runner
.
global_step
,
10
)
def
test_has_checkpoint_no_summaries
(
self
):
test_runner
=
TestRunner
()
# Has checkpoint, but no summary directories.
checkpoint
=
tf
.
train
.
Checkpoint
(
model
=
test_runner
.
model
)
checkpoint_manager
=
tf
.
train
.
CheckpointManager
(
checkpoint
,
self
.
model_dir
,
max_to_keep
=
None
,
step_counter
=
test_runner
.
global_step
)
test_controller
=
controller
.
Controller
(
trainer
=
test_runner
,
evaluator
=
test_runner
,
global_step
=
test_runner
.
global_step
,
checkpoint_manager
=
checkpoint_manager
,
steps_per_loop
=
2
)
test_controller
.
train_and_evaluate
(
train_steps
=
10
,
eval_steps
=
2
,
eval_interval
=
6
)
self
.
assertEqual
(
test_runner
.
global_step
,
10
)
# No summaries are saved.
self
.
assertEmpty
(
tf
.
io
.
gfile
.
glob
(
os
.
path
.
join
(
checkpoint_manager
.
directory
,
"events.*"
)))
def
test_has_checkpoint_eval_summary_only
(
self
):
test_runner
=
TestRunner
()
# Has checkpoint, but no summary directories.
checkpoint
=
tf
.
train
.
Checkpoint
(
model
=
test_runner
.
model
)
checkpoint_manager
=
tf
.
train
.
CheckpointManager
(
checkpoint
,
self
.
model_dir
,
max_to_keep
=
None
,
step_counter
=
test_runner
.
global_step
)
test_controller
=
controller
.
Controller
(
trainer
=
test_runner
,
evaluator
=
test_runner
,
global_step
=
test_runner
.
global_step
,
checkpoint_manager
=
checkpoint_manager
,
eval_summary_dir
=
os
.
path
.
join
(
self
.
model_dir
,
"summaries/eval"
),
steps_per_loop
=
2
)
test_controller
.
train_and_evaluate
(
train_steps
=
10
,
eval_steps
=
2
,
eval_interval
=
6
)
self
.
assertEqual
(
test_runner
.
global_step
,
10
)
# Training summaries are not saved.
self
.
assertEmpty
(
tf
.
io
.
gfile
.
glob
(
os
.
path
.
join
(
checkpoint_manager
.
directory
,
"events.*"
)))
# Evaluation summaries are saved.
self
.
assertNotEmpty
(
tf
.
io
.
gfile
.
glob
(
os
.
path
.
join
(
self
.
model_dir
,
"summaries/eval/events.*"
)))
@
parameterized
.
named_parameters
((
"return_numpy"
,
True
),
(
"return_tensor"
,
False
))
def
test_train_and_evaluate
(
self
,
return_numpy
):
...
...
@@ -612,7 +662,8 @@ class ControllerTest(tf.test.TestCase, parameterized.TestCase):
evaluator
=
test_runner
,
global_step
=
test_runner
.
global_step
,
steps_per_loop
=
10
,
checkpoint_manager
=
checkpoint_manager
)
checkpoint_manager
=
checkpoint_manager
,
summary_dir
=
self
.
model_dir
)
test_controller
.
train_and_evaluate
(
train_steps
=
10
,
eval_steps
=
2
,
eval_interval
=
5
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录