keras load model with custom optimizer

keras load model with custom optimizer

Guide

error

when load model with custom optimizer, eg RAdam()

model = load_model("resnet50_radam_model.h5")

output error

ValueError: Unknown optimizer: RAdam

solution

1
2
3
4
5
6
7
from keras_radam import RAdam
from keras.utils import CustomObjectScope

with CustomObjectScope({'RAdam': RAdam()}):
best_model_filepath = "./checkpoint/best_model_efnb0.h5"
model = load_model(best_model_filepath)
model.save_weights("./checkpoint/weights_efnb0.h5")

Reference

History

  • 20190920: created.
赞赏