Discussions>Keras model to tflite>

Keras model to tflite

I've got a Keras model in the hdf5 file and wanted to convert it into tflite, but I've got an issue like this

model = 'model.h5'
converter = tf.lite.TFLiteConverter.from_keras_model_file(model)
tflite_model = converter.convert()
open("converted/model.tflite", "wb").write(tflite_model)

ValueError: Unknown loss function:custom_loss

I know that I should load my custom loss as custom_object, but I can't find a way to it with TensorFlow function. What is the solution for this?

3 votesLP262.00
1 Answers

Currently tensorflow (until v1.13.*) does not let you to pass custom_objects through their api. If you take a look at the code, you will see

keras_model = _keras.models.load_model(model_file)

The issue related to this is already opened and currently is in process of review.


Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?