自学教程:keras——ValueError: You are trying to load a weight file containing 12 layers into a model with 2 lay |
51自学网 2021-11-15 09:23:24 |
Keras |
|
这篇教程keras——ValueError: You are trying to load a weight file containing 12 layers into a model with 2 lay写得很实用,希望能帮到您。 keras——ValueError: You are trying to load a weight file containing 12 layers into a model with 2 layers.
>> model.save('./model/my_model_weights.h5')
>> model=load_model('./model/my_model_weights.h5')
ValueError: You are trying to load a weight file containing 12 layers into a model with 2 layers.
因为这个神经网络是嵌套的,也算是这个python库的一个bug吧。
from keras.models import model_from_json
>> model.save_weights('test.h5')
>> model.load_weights('test.h5',by_name=True)
>> json_string = model.to_json()
>> model = model_from_json(json_string)
这样就可以运行了。 Keras中出现意外的关键字参数“ragged”解决办法 Keras CIFAR-10彩色图像物体识别 卷积神经网络 |
|