Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wux_labs
Tensorflow
提交
868f22ad
T
Tensorflow
项目概览
wux_labs
/
Tensorflow
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
868f22ad
编写于
6月 04, 2019
作者:
P
Pavithra Vijay
提交者:
TensorFlower Gardener
6月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deserializing loss class in hdf5 format.
PiperOrigin-RevId: 251579891
上级
69b121d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
2 deletion
+7
-2
tensorflow/python/keras/saving/hdf5_format.py
tensorflow/python/keras/saving/hdf5_format.py
+5
-1
tensorflow/python/keras/saving/hdf5_format_test.py
tensorflow/python/keras/saving/hdf5_format_test.py
+2
-1
未找到文件。
tensorflow/python/keras/saving/hdf5_format.py
浏览文件 @
868f22ad
...
...
@@ -26,6 +26,7 @@ import numpy as np
from
six.moves
import
zip
# pylint: disable=redefined-builtin
from
tensorflow.python.keras
import
backend
as
K
from
tensorflow.python.keras
import
losses
from
tensorflow.python.keras
import
optimizers
from
tensorflow.python.keras.saving
import
model_config
as
model_config_lib
from
tensorflow.python.keras.saving
import
saving_utils
...
...
@@ -202,7 +203,10 @@ def load_model_from_hdf5(filepath, custom_objects=None, compile=True): # pylint
optimizer_config
,
custom_objects
=
custom_objects
)
# Recover loss functions and metrics.
loss
=
convert_custom_objects
(
training_config
[
'loss'
])
loss_config
=
training_config
[
'loss'
]
# Deserialize loss class.
if
isinstance
(
loss_config
,
dict
)
and
'class_name'
in
loss_config
:
loss_config
=
losses
.
get
(
loss_config
)
loss
=
convert_custom_objects
(
loss_config
)
metrics
=
convert_custom_objects
(
training_config
[
'metrics'
])
weighted_metrics
=
convert_custom_objects
(
training_config
.
get
(
'weighted_metrics'
,
None
))
...
...
tensorflow/python/keras/saving/hdf5_format_test.py
浏览文件 @
868f22ad
...
...
@@ -662,7 +662,8 @@ class TestWholeModelSaving(test.TestCase):
for
i
in
range
(
4
):
f
=
keras
.
layers
.
Dense
(
2
,
name
=
'dense_%d'
%
(
i
,))(
f
)
model
=
keras
.
Model
(
inputs
=
[
x
],
outputs
=
[
f
])
model
.
compile
(
loss
=
'mse'
,
optimizer
=
'adam'
,
metrics
=
[
'acc'
])
model
.
compile
(
'adam'
,
loss
=
keras
.
losses
.
MeanSquaredError
(),
metrics
=
[
'acc'
])
x
=
np
.
random
.
random
((
1
,
2
))
y
=
np
.
random
.
random
((
1
,
2
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录