I’m not sure I understand your question correctly. Does the error occur when you are saving the keras model into .h5 file or loading it from it?
If you are loading a model from a file and see messages about unknown layers, it mean that the original model contained some custom layers. You need to import them or initialize from scratch in your new code before loading the model.