Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38905368
tensorflow
提交
1602ac6a
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,发现更多精彩内容 >>
提交
1602ac6a
编写于
6月 21, 2016
作者:
I
Illia Polosukhin
提交者:
TensorFlower Gardener
6月 21, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix typo in the run_local call of Experiment. Added test for run_local.
Change: 125458571
上级
002e1854
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
1 deletion
+21
-1
tensorflow/contrib/learn/python/learn/experiment.py
tensorflow/contrib/learn/python/learn/experiment.py
+2
-1
tensorflow/contrib/learn/python/learn/tests/experiment_test.py
...rflow/contrib/learn/python/learn/tests/experiment_test.py
+19
-0
未找到文件。
tensorflow/contrib/learn/python/learn/experiment.py
浏览文件 @
1602ac6a
...
@@ -121,9 +121,10 @@ class Experiment(object):
...
@@ -121,9 +121,10 @@ class Experiment(object):
Returns:
Returns:
The result of the `evaluate` call to the `Estimator`.
The result of the `evaluate` call to the `Estimator`.
"""
"""
self
.
_train_monitors
=
self
.
_train_monitors
or
[]
if
self
.
_local_eval_frequency
:
if
self
.
_local_eval_frequency
:
self
.
_train_monitors
+=
[
monitors
.
ValidationMonitor
(
self
.
_train_monitors
+=
[
monitors
.
ValidationMonitor
(
input_fn
=
self
.
_eval_input_fn
,
steps
=
self
.
_eval_steps
,
input_fn
=
self
.
_eval_input_fn
,
eval_
steps
=
self
.
_eval_steps
,
metrics
=
self
.
_eval_metrics
,
every_n_steps
=
self
.
_local_eval_frequency
metrics
=
self
.
_eval_metrics
,
every_n_steps
=
self
.
_local_eval_frequency
)]
)]
self
.
train
()
self
.
train
()
...
...
tensorflow/contrib/learn/python/learn/tests/experiment_test.py
浏览文件 @
1602ac6a
...
@@ -27,6 +27,7 @@ class TestEstimator(object):
...
@@ -27,6 +27,7 @@ class TestEstimator(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
eval_count
=
0
self
.
eval_count
=
0
self
.
fit_count
=
0
self
.
fit_count
=
0
self
.
monitors
=
[]
def
evaluate
(
self
,
**
kwargs
):
def
evaluate
(
self
,
**
kwargs
):
tf
.
logging
.
info
(
'evaluate called with args: %s'
%
kwargs
)
tf
.
logging
.
info
(
'evaluate called with args: %s'
%
kwargs
)
...
@@ -39,6 +40,8 @@ class TestEstimator(object):
...
@@ -39,6 +40,8 @@ class TestEstimator(object):
def
fit
(
self
,
**
kwargs
):
def
fit
(
self
,
**
kwargs
):
tf
.
logging
.
info
(
'fit called with args: %s'
%
kwargs
)
tf
.
logging
.
info
(
'fit called with args: %s'
%
kwargs
)
self
.
fit_count
+=
1
self
.
fit_count
+=
1
if
'monitors'
in
kwargs
:
self
.
monitors
=
kwargs
[
'monitors'
]
return
[(
key
,
kwargs
[
key
])
for
key
in
sorted
(
kwargs
.
keys
())]
return
[(
key
,
kwargs
[
key
])
for
key
in
sorted
(
kwargs
.
keys
())]
...
@@ -115,6 +118,22 @@ class ExperimentTest(tf.test.TestCase):
...
@@ -115,6 +118,22 @@ class ExperimentTest(tf.test.TestCase):
tf
.
logging
.
info
(
'eval duration (expected %f): %f'
,
expected
,
duration
)
tf
.
logging
.
info
(
'eval duration (expected %f): %f'
,
expected
,
duration
)
self
.
assertTrue
(
duration
>
expected
-
0.5
and
duration
<
expected
+
0.5
)
self
.
assertTrue
(
duration
>
expected
-
0.5
and
duration
<
expected
+
0.5
)
def
test_run_local
(
self
):
est
=
TestEstimator
()
ex
=
tf
.
contrib
.
learn
.
Experiment
(
est
,
train_input_fn
=
'train_input'
,
eval_input_fn
=
'eval_input'
,
eval_metrics
=
'eval_metrics'
,
train_steps
=
100
,
eval_steps
=
100
,
local_eval_frequency
=
10
)
ex
.
local_run
()
self
.
assertEquals
(
1
,
est
.
fit_count
)
self
.
assertEquals
(
1
,
est
.
eval_count
)
self
.
assertEquals
(
1
,
len
(
est
.
monitors
))
self
.
assertTrue
(
isinstance
(
est
.
monitors
[
0
],
tf
.
contrib
.
learn
.
monitors
.
ValidationMonitor
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
tf
.
test
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录