异想天开

What's the true meaning of light, Could you tell me why

【出错记录】ValueError: Cannot create group in read only mode.

日期:2020-03-18 17:45:37
  
最后更新日期:2020-03-18 17:45:37
调用kerase里面的load_model出现如下报错:
File "./h5_2_pb.py", line 47, in h5_model = load_model(weight_file_path)
File "python3.6/site-packages/keras/engine/saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "python3.6/site-packages/keras/engine/saving.py", line 221, in _deserialize_model
model_config = f['model_config']
File "python3.6/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.
对比两次模型,新的模型少了100k字节,原因在用新的模型保存用了save_weights,仅仅保存了参数,没有保存meta信息。解决办法,用带有模型的代码,重新调用kerase里面save函数即可,就会保存meta和参数了。