Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tensorflow as tf
- model = tf.keras.models.Sequential([
- tf.keras.layers.Dense(10, activation='relu', input_shape=(100,0)),
- tf.keras.layers.Dense(1, activation='sigmoid')
- ])
- model.save('/home/ubuntu/models/model_prova.keras')
- print("Modello salvato correttamente")
- try:
- model = tf.keras.models.load_model('/home/ubuntu/models/model_prova.keras')
- print("Modello caricato correttamente")
- converter = tf.lite.TFLiteConverter.from_keras_model(model)
- tflite_model = converter.convert()
- print("Modello convertito correttamente")
- tflite_model_path = '/home/ubuntu/models/model.tflite'
- with open(tflite_model_path, "wb") as f:
- f.write(tflite_model)
- print(f"Modello TFLite salvato correttamente in : {tflite_model_path}")
- except Exception as e:
- print(f"Errore durante la conversione: {e}")
Advertisement
Add Comment
Please, Sign In to add comment