Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38905368
tensorflow
提交
e412f6aa
T
tensorflow
项目概览
qq_38905368
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e412f6aa
编写于
6月 24, 2016
作者:
M
Mustafa Ispir
提交者:
TensorFlower Gardener
6月 24, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added staggered start of training workers.
Change: 125803613
上级
0c1285bf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
15 deletion
+36
-15
tensorflow/contrib/learn/python/learn/experiment.py
tensorflow/contrib/learn/python/learn/experiment.py
+18
-9
tensorflow/contrib/learn/python/learn/runner_flags.py
tensorflow/contrib/learn/python/learn/runner_flags.py
+1
-2
tensorflow/contrib/learn/python/learn/tests/experiment_test.py
...rflow/contrib/learn/python/learn/tests/experiment_test.py
+17
-4
未找到文件。
tensorflow/contrib/learn/python/learn/experiment.py
浏览文件 @
e412f6aa
...
...
@@ -24,8 +24,11 @@ import time
from
tensorflow.contrib.learn.python.learn
import
monitors
from
tensorflow.contrib.learn.python.learn.estimators._sklearn
import
NotFittedError
from
tensorflow.python.platform
import
flags
from
tensorflow.python.platform
import
tf_logging
as
logging
FLAGS
=
flags
.
FLAGS
class
Experiment
(
object
):
"""Experiment is a class containing all information needed to train a model.
...
...
@@ -70,7 +73,7 @@ class Experiment(object):
self
.
_train_monitors
=
train_monitors
self
.
_local_eval_frequency
=
local_eval_frequency
def
train
(
self
,
delay_secs
=
0
):
def
train
(
self
,
delay_secs
=
None
):
"""Fit the estimator using the training data.
Train the estimator for `steps` steps, after waiting for `delay_secs`
...
...
@@ -83,6 +86,12 @@ class Experiment(object):
The trained estimator.
"""
if
delay_secs
is
None
:
task_id
=
0
if
"task"
in
FLAGS
:
task_id
=
FLAGS
.
task
delay_secs
=
min
(
60
,
task_id
*
5
)
if
delay_secs
:
logging
.
info
(
"Waiting %d secs before starting training."
,
delay_secs
)
time
.
sleep
(
delay_secs
)
...
...
@@ -91,7 +100,7 @@ class Experiment(object):
max_steps
=
self
.
_train_steps
,
monitors
=
self
.
_train_monitors
)
def
evaluate
(
self
,
delay_secs
=
0
):
def
evaluate
(
self
,
delay_secs
=
12
0
):
"""Evaluate on the evaluation data.
Runs evaluation on the evaluation data and returns the result. If `steps`
...
...
@@ -127,13 +136,13 @@ class Experiment(object):
input_fn
=
self
.
_eval_input_fn
,
eval_steps
=
self
.
_eval_steps
,
metrics
=
self
.
_eval_metrics
,
every_n_steps
=
self
.
_local_eval_frequency
)]
self
.
train
()
return
self
.
evaluate
()
self
.
train
(
delay_secs
=
0
)
return
self
.
evaluate
(
delay_secs
=
0
)
def
_continuous_eval
(
self
,
input_fn
,
name
,
delay_secs
=
0
,
delay_secs
=
12
0
,
throttle_delay_secs
=
60
):
"""Run continuous eval.
...
...
@@ -160,8 +169,7 @@ class Experiment(object):
metrics
=
self
.
_eval_metrics
,
name
=
name
)
except
NotFittedError
:
logging
.
warning
(
"Estimator is not fitted yet, skipping evaluation. "
"Increase 'delay_secs' to avoid this warning."
)
logging
.
warning
(
"Estimator is not fitted yet, skipping evaluation."
)
duration
=
time
.
time
()
-
start
if
duration
<
throttle_delay_secs
:
difference
=
throttle_delay_secs
-
duration
...
...
@@ -169,13 +177,14 @@ class Experiment(object):
difference
)
time
.
sleep
(
difference
)
def
continuous_eval
(
self
,
delay_secs
=
0
,
throttle_delay_secs
=
60
):
def
continuous_eval
(
self
,
delay_secs
=
12
0
,
throttle_delay_secs
=
60
):
self
.
_continuous_eval
(
self
.
_eval_input_fn
,
name
=
"continuous"
,
delay_secs
=
delay_secs
,
throttle_delay_secs
=
throttle_delay_secs
)
def
continuous_eval_on_train_data
(
self
,
delay_secs
=
0
,
throttle_delay_secs
=
60
):
def
continuous_eval_on_train_data
(
self
,
delay_secs
=
120
,
throttle_delay_secs
=
60
):
self
.
_continuous_eval
(
self
.
_train_input_fn
,
name
=
"continuous_on_train_data"
,
delay_secs
=
delay_secs
,
...
...
tensorflow/contrib/learn/python/learn/runner_flags.py
浏览文件 @
e412f6aa
...
...
@@ -32,5 +32,4 @@ flags.DEFINE_string('schedule', 'local_run',
'instance returned by the function passed to the '
'run() call'
)
# TODO(ispir): Remove once we migrated customer pipilines.
flags
.
DEFINE_string
(
'execution_mode'
,
'all'
,
'Deprecated. Use FLAGS.schedule'
)
flags
.
DEFINE_integer
(
'task'
,
0
,
'Task id of the replica running the training.'
)
tensorflow/contrib/learn/python/learn/tests/experiment_test.py
浏览文件 @
e412f6aa
...
...
@@ -20,6 +20,8 @@ from __future__ import print_function
import
time
import
tensorflow
as
tf
# importing to get flags.
from
tensorflow.contrib.learn.python.learn
import
runner_flags
# pylint: disable=unused-import
class
TestEstimator
(
object
):
...
...
@@ -68,8 +70,19 @@ class ExperimentTest(tf.test.TestCase):
start
=
time
.
time
()
ex
.
train
(
delay_secs
=
delay
)
duration
=
time
.
time
()
-
start
tf
.
logging
.
info
(
'train duration (expected %f): %f'
,
delay
,
duration
)
self
.
assertTrue
(
duration
>
delay
-
0.5
and
duration
<
delay
+
0.5
)
self
.
assertAlmostEqual
(
duration
,
delay
,
delta
=
0.5
)
def
test_train_default_delay
(
self
):
est
=
TestEstimator
()
ex
=
tf
.
contrib
.
learn
.
Experiment
(
est
,
train_input_fn
=
'train_input'
,
eval_input_fn
=
'eval_input'
)
for
task
in
[
0
,
1
,
3
]:
start
=
time
.
time
()
tf
.
flags
.
FLAGS
.
task
=
task
ex
.
train
()
duration
=
time
.
time
()
-
start
self
.
assertAlmostEqual
(
duration
,
task
*
5
,
delta
=
0.5
)
def
test_evaluate
(
self
):
est
=
TestEstimator
()
...
...
@@ -92,7 +105,7 @@ class ExperimentTest(tf.test.TestCase):
ex
.
evaluate
(
delay_secs
=
delay
)
duration
=
time
.
time
()
-
start
tf
.
logging
.
info
(
'eval duration (expected %f): %f'
,
delay
,
duration
)
self
.
assert
True
(
duration
>
delay
-
0.5
and
duration
<
delay
+
0.5
)
self
.
assert
AlmostEqual
(
duration
,
delay
,
delta
=
0.5
)
def
test_continuous_eval
(
self
):
est
=
TestEstimator
()
...
...
@@ -118,7 +131,7 @@ class ExperimentTest(tf.test.TestCase):
duration
=
time
.
time
()
-
start
expected
=
5
*
delay
tf
.
logging
.
info
(
'eval duration (expected %f): %f'
,
expected
,
duration
)
self
.
assert
True
(
duration
>
expected
-
0.5
and
duration
<
expected
+
0.5
)
self
.
assert
AlmostEqual
(
duration
,
expected
,
delta
=
0.5
)
def
test_run_local
(
self
):
est
=
TestEstimator
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录