Loading a model created and trained in Keras 2. in new Keras 3.7 env for inference #20687
Labels
type:support
User is asking for help / asking an implementation question. Stackoverflow would be better suited.
I am working on a computer vision project and I have this model that is trained in Keras 2. and saved as an .h5 file.
In the 'old' Keras 2. environment, I can load the model with custom and run predict just fine.
Here's the code snippet I use for loading model and custom eswish activation function.
Here is the specification for the 'old' environment:
Python 3.7
Tensorflow 2.6
Keras 2.6
Now, I want to run inference with this model in 'new' environment. Specifcation for the 'new' environment.
Python 3.12
Tensorflow 2.16.1
Keras 3.0
I understand that loading old model with
keras.model.load_model
is no longer usable in Keras 3. So currently I am trying to export the model's config and weights tomodel.json
andmodel.weights.h5
seperately then load these files in new Keras 3.0 environment.The problem is that the model has custom activation function and layers. I have the definition for these custom activation function and layers. The question is how can I export the config of the model to
.json
with these custom functions and layers? Here's the code snippet for what I'm trying to do.In 'old' Keras 2. environment:
The text was updated successfully, but these errors were encountered: