#For reducing the size of model while keeping accuracy same for faster inference import tensorflow as tf from tensorflow.keras.models import load_model # Model Loading model = load_model("models/bilstm_fake_news_model.h5") # Conversion with TFLiteConverter converter = tf.lite.TFLiteConverter.from_keras_model(model) converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.target_spec.supported_types = [tf.float16] converter.target_spec.supported_ops = [ tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS ] converter._experimental_lower_tensor_list_ops = False tflite_model = converter.convert() # Saving with open("models/bilstm_fake_news_float16.tflite", "wb") as f: f.write(tflite_model)