Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_40195168达庆意
keras
提交
ecac367b
K
keras
项目概览
weixin_40195168达庆意
/
keras
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
keras
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ecac367b
编写于
10月 22, 2019
作者:
T
Thibault Buhet
提交者:
Gabriel de Marmiesse
10月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix h5py group naming while model saving (#13477)
上级
4d59675b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
3 deletion
+20
-3
keras/engine/saving.py
keras/engine/saving.py
+3
-1
tests/keras/metrics_training_test.py
tests/keras/metrics_training_test.py
+1
-1
tests/test_model_saving.py
tests/test_model_saving.py
+16
-1
未找到文件。
keras/engine/saving.py
浏览文件 @
ecac367b
...
...
@@ -744,7 +744,9 @@ def save_weights_to_hdf5_group(group, layers):
group
.
attrs
[
'backend'
]
=
K
.
backend
().
encode
(
'utf8'
)
group
.
attrs
[
'keras_version'
]
=
str
(
keras_version
).
encode
(
'utf8'
)
for
layer
in
layers
:
# Sort model layers by layer name to ensure that group names are strictly
# growing to avoid prefix issues.
for
layer
in
sorted
(
layers
,
key
=
lambda
x
:
x
.
name
):
g
=
group
.
create_group
(
layer
.
name
)
symbolic_weights
=
layer
.
weights
weight_values
=
K
.
batch_get_value
(
symbolic_weights
)
...
...
tests/keras/metrics_training_test.py
浏览文件 @
ecac367b
...
...
@@ -80,7 +80,7 @@ def test_sensitivity_metrics():
model
.
evaluate
(
x
,
y
)
@
pytest
.
mark
.
skipif
(
K
.
backend
()
!=
'tensorflow'
,
reason
=
'requires tensorflow
'
)
@
pytest
.
mark
.
skipif
(
True
,
reason
=
'It is a flaky test, see #13477 for more context.
'
)
def
test_mean_iou
():
import
tensorflow
as
tf
if
not
tf
.
__version__
.
startswith
(
'2.'
):
...
...
tests/test_model_saving.py
浏览文件 @
ecac367b
...
...
@@ -14,7 +14,7 @@ from keras.engine.saving import preprocess_weights_for_loading
from
keras.models
import
Model
,
Sequential
from
keras.layers
import
Dense
,
Lambda
,
RepeatVector
,
TimeDistributed
from
keras.layers
import
Bidirectional
,
GRU
,
LSTM
,
CuDNNGRU
,
CuDNNLSTM
from
keras.layers
import
Conv2D
,
Flatten
from
keras.layers
import
Conv2D
,
Flatten
,
Activation
from
keras.layers
import
Input
,
InputLayer
from
keras.initializers
import
Constant
from
keras
import
optimizers
...
...
@@ -708,6 +708,21 @@ def test_saving_constant_initializer_with_numpy():
os
.
remove
(
fname
)
def
test_saving_group_naming_h5py
(
tmpdir
):
"""Test saving model with layer which name is prefix to a previous layer
name
"""
input_layer
=
Input
((
None
,
None
,
3
),
name
=
'test_input'
)
x
=
Conv2D
(
1
,
1
,
name
=
'conv1/conv'
)(
input_layer
)
x
=
Activation
(
'relu'
,
name
=
'conv1'
)(
x
)
model
=
Model
(
inputs
=
input_layer
,
outputs
=
x
)
p
=
tmpdir
.
mkdir
(
"test"
).
join
(
"test.h5"
)
model
.
save_weights
(
p
)
model
.
load_weights
(
p
)
def
test_save_load_weights_gcs
():
model
=
Sequential
()
model
.
add
(
Dense
(
2
,
input_shape
=
(
3
,)))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录