0
votes

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

1
Have you tried without the ".h5" at the end? - ML_Engine
yes, I have tried many variations. ".h5", without extension, ".tf", ".hpy5" etc. model.save() does not work in any case except ".hpy5", but then model.load(".hpy5") does not work. - Irfan Umar
Ok, are you re-compiling the model after loading the weights? - ML_Engine
I am just doing this model = model.load_weights(model_path) and then the training loop continues as usual - Irfan Umar
Ok I think you need to re-compile the model after loading the weights. Load weights only loads the weights, so you need to re-create the model structure (your layers), the optimizer and the loss and then compile them before fitting. - ML_Engine

1 Answers

0
votes

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.