Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
tensorflow
提交
2f46b74c
T
tensorflow
项目概览
xxadev
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
1
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,发现更多精彩内容 >>
提交
2f46b74c
编写于
3月 17, 2017
作者:
M
Mustafa Ispir
提交者:
TensorFlower Gardener
3月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test graph initialization logic in Estimator.
Change: 150479545
上级
86fae6bd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
3 deletion
+76
-3
tensorflow/python/estimator/estimator.py
tensorflow/python/estimator/estimator.py
+1
-0
tensorflow/python/estimator/estimator_test.py
tensorflow/python/estimator/estimator_test.py
+75
-3
未找到文件。
tensorflow/python/estimator/estimator.py
浏览文件 @
2f46b74c
...
...
@@ -392,6 +392,7 @@ class Estimator(object):
with
ops
.
Graph
().
as_default
()
as
g
:
training
.
create_global_step
(
g
)
random_seed
.
set_random_seed
(
self
.
_config
.
tf_random_seed
)
serving_input_receiver
=
serving_input_receiver_fn
()
# Call the model_fn and collect the export_outputs.
...
...
tensorflow/python/estimator/estimator_test.py
浏览文件 @
2f46b74c
...
...
@@ -186,7 +186,8 @@ class EstimatorConstructorTest(test.TestCase):
def
dummy_input_fn
():
return
{
'x'
:
[[
1
],
[
1
]]},
[[
1
],
[
1
]]
return
({
'x'
:
constant_op
.
constant
([[
1
],
[
1
]])},
constant_op
.
constant
([[
1
],
[
1
]]))
def
model_fn_global_step_incrementer
(
features
,
labels
,
mode
):
...
...
@@ -357,7 +358,7 @@ class EstimatorTrainTest(test.TestCase):
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
(
0.
))
predictions
=
constant_op
.
constant
(
[[
0.
]]
))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
_input_fn
,
steps
=
1
)
...
...
@@ -365,6 +366,21 @@ class EstimatorTrainTest(test.TestCase):
self
.
assertEqual
(
given_labels
,
self
.
labels
)
self
.
assertEqual
(
model_fn_lib
.
ModeKeys
.
TRAIN
,
self
.
mode
)
def
test_graph_initialization_global_step_and_random_seed
(
self
):
expected_random_seed
=
run_config
.
RunConfig
().
tf_random_seed
def
_model_fn
(
features
,
labels
,
mode
):
_
,
_
,
_
=
features
,
labels
,
mode
self
.
assertIsNotNone
(
training
.
get_global_step
())
self
.
assertEqual
(
expected_random_seed
,
ops
.
get_default_graph
().
seed
)
return
model_fn_lib
.
EstimatorSpec
(
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
([[
0.
]]))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
dummy_input_fn
,
steps
=
1
)
def
_model_fn_with_eval_metric_ops
(
features
,
labels
,
mode
,
params
):
_
,
_
=
features
,
labels
...
...
@@ -552,7 +568,7 @@ class EstimatorEvaluateTest(test.TestCase):
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
(
0.
))
predictions
=
constant_op
.
constant
(
[[
0.
]]
))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
_input_fn
,
steps
=
1
)
...
...
@@ -561,6 +577,22 @@ class EstimatorEvaluateTest(test.TestCase):
self
.
assertEqual
(
given_labels
,
self
.
labels
)
self
.
assertEqual
(
model_fn_lib
.
ModeKeys
.
EVAL
,
self
.
mode
)
def
test_graph_initialization_global_step_and_random_seed
(
self
):
expected_random_seed
=
run_config
.
RunConfig
().
tf_random_seed
def
_model_fn
(
features
,
labels
,
mode
):
_
,
_
,
_
=
features
,
labels
,
mode
self
.
assertIsNotNone
(
training
.
get_global_step
())
self
.
assertEqual
(
expected_random_seed
,
ops
.
get_default_graph
().
seed
)
return
model_fn_lib
.
EstimatorSpec
(
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
([[
0.
]]))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
dummy_input_fn
,
steps
=
1
)
est
.
evaluate
(
dummy_input_fn
,
steps
=
1
)
class
EstimatorPredictTest
(
test
.
TestCase
):
...
...
@@ -816,6 +848,22 @@ class EstimatorPredictTest(test.TestCase):
self
.
assertIsNone
(
self
.
labels
)
self
.
assertEqual
(
model_fn_lib
.
ModeKeys
.
PREDICT
,
self
.
mode
)
def
test_graph_initialization_global_step_and_random_seed
(
self
):
expected_random_seed
=
run_config
.
RunConfig
().
tf_random_seed
def
_model_fn
(
features
,
labels
,
mode
):
_
,
_
,
_
=
features
,
labels
,
mode
self
.
assertIsNotNone
(
training
.
get_global_step
())
self
.
assertEqual
(
expected_random_seed
,
ops
.
get_default_graph
().
seed
)
return
model_fn_lib
.
EstimatorSpec
(
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
([[
0.
]]))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
dummy_input_fn
,
steps
=
1
)
next
(
est
.
predict
(
dummy_input_fn
))
def
_model_fn_for_export_tests
(
features
,
labels
,
mode
):
_
,
_
=
features
,
labels
...
...
@@ -1139,6 +1187,30 @@ class EstimatorExportTest(test.TestCase):
self
.
assertIsNone
(
self
.
labels
)
self
.
assertEqual
(
model_fn_lib
.
ModeKeys
.
PREDICT
,
self
.
mode
)
def
test_graph_initialization_global_step_and_random_seed
(
self
):
expected_random_seed
=
run_config
.
RunConfig
().
tf_random_seed
def
_model_fn
(
features
,
labels
,
mode
):
_
,
_
,
_
=
features
,
labels
,
mode
self
.
assertIsNotNone
(
training
.
get_global_step
())
self
.
assertEqual
(
expected_random_seed
,
ops
.
get_default_graph
().
seed
)
return
model_fn_lib
.
EstimatorSpec
(
mode
=
mode
,
loss
=
constant_op
.
constant
(
0.
),
train_op
=
constant_op
.
constant
(
0.
),
predictions
=
constant_op
.
constant
([[
0.
]]),
export_outputs
=
{
'test'
:
export
.
ClassificationOutput
(
constant_op
.
constant
([[
0.
]]))
})
def
serving_input_receiver_fn
():
return
export
.
ServingInputReceiver
(
{
'test-features'
:
constant_op
.
constant
([[
1
],
[
1
]])},
array_ops
.
placeholder
(
dtype
=
dtypes
.
string
))
est
=
estimator
.
Estimator
(
model_fn
=
_model_fn
)
est
.
train
(
dummy_input_fn
,
steps
=
1
)
est
.
export_savedmodel
(
tempfile
.
mkdtemp
(),
serving_input_receiver_fn
)
class
EstimatorIntegrationTest
(
test
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录