import tensorflow as tf # Assume you have a trained model already (replace with your own model code) model = tf.keras.Sequential([ tf.keras.layers.Dense(128, activation='relu', input_shape=(784,)), tf.keras.layers.Dense(10, activation='softmax') ]) # Save the model to a file model.save('my_model.h5') # Save in HDF5 format print("Model saved successfully!")