简体   繁体   中英

Training a keras model on pretrained weights using load_weights()

I am using a custom keras model in Databricks environment. For a custom keras model, model.save(model.h5) does not work, because custom model is not serializable. Instead it is recommended to use model.save_weights(path) as an alternate.

model.save_weights(pathDirectory) works. This yields 3 files checkpoint , .data-00000-of-00001 , .index in the pathDirectory

For loading weights, Following mechanism is working fine.

model = Model()

model.load_weights(path)

But I want to train my model on pretrained weights I just saved. Like I saved model weights, and continue training on these saved weights afterwards.

So, when I load model weights and apply training loop, I get this error, TypeError: 'CheckpointLoadStatus' object is not callable

After much research, I have found a workaround,

we can also save model using model.save("model.hpy5") and read it the saved model in databricks.

model.h5 not work for customized models, but it works for standard models.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM