ValueError: Cannot create group in read only mode.
原文链接:http://www.one2know.cn/bug7/
- 报错
Using TensorFlow backend.
Traceback (most recent call last):
File "D:/PyCharm 5.0.3/WorkSpace/3.Keras/2.Application中五款已训练模型、VGG16框架(Sequential式、Model式)解读/1.py", line 8, in <module>
model = load_model(r'..\Model\resnet50_weights_tf_dim_ordering_tf_kernels.h5','rw')
File "D:\Anaconda3\lib\site-packages\keras\engine\saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "D:\Anaconda3\lib\site-packages\keras\engine\saving.py", line 221, in _deserialize_model
model_config = f['model_config']
File "D:\Anaconda3\lib\site-packages\keras\utils\io_utils.py", line 302, in __getitem__
raise ValueError('Cannot create group in read only mode.')
ValueError: Cannot create group in read only mode.
- 原因
单纯的没有结构一个model不能导入那么多参数 - 解决
model = AModel(weights=r'模型的路径\model_name.h5')
也可以:
先加载model的layers,再加载模型