Official_Lusi

problema tf

Jul 10th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import tensorflow as tf
  2.  
  3. model = tf.keras.models.Sequential([
  4. tf.keras.layers.Dense(10, activation='relu', input_shape=(100,0)),
  5. tf.keras.layers.Dense(1, activation='sigmoid')
  6. ])
  7.  
  8. model.save('/home/ubuntu/models/model_prova.keras')
  9. print("Modello salvato correttamente")
  10.  
  11. try:
  12. model = tf.keras.models.load_model('/home/ubuntu/models/model_prova.keras')
  13. print("Modello caricato correttamente")
  14.  
  15. converter = tf.lite.TFLiteConverter.from_keras_model(model)
  16. tflite_model = converter.convert()
  17. print("Modello convertito correttamente")
  18.  
  19. tflite_model_path = '/home/ubuntu/models/model.tflite'
  20. with open(tflite_model_path, "wb") as f:
  21. f.write(tflite_model)
  22. print(f"Modello TFLite salvato correttamente in : {tflite_model_path}")
  23. except Exception as e:
  24. print(f"Errore durante la conversione: {e}")
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment