After we trained a Neural Network, we can save it in order to be able to predict without re-training. So when we use model.save('my_model.keras') what exactly is being saved?

tensorflow tutorial says:

Save a model's architecture, weights, and training configuration in a single model.keras zip archive.

What exactly does it mean "model's architecture, weights, and training configuration". Is it a set of matrices? Or is there a better way to visualize it?

For reference here is my model:

model = Sequential()
model.add(Masking(mask_value=0., input_shape=(X_train_scaled.shape[1],)))
model.add(Dense(64, activation='relu'))
model.add(Dense(42, activation='relu'))
model.add(Dense(1, activation='linear'))  # Linear activation for regression
model.compile(optimizer='adam', loss='mean_absolute_error')

1 Answer 1


The saved data comprises:

  • Model's architecture: so, which layers your model has (Masking, Dense, Dense, Dense), their definition (e.g. the input/output shapes, activations, mask_value = 0 for the Masking layer, etc), and how they are connected (i.e. Masking --> Dense --> Dense --> Dense).
  • Weights: the trainable parameter values of each layer (e.g. kernel and bias for Dense layers). These are the matrices that you were referring to in your question.
  • Training configuration: optimizer, loss.

The goal is to save all data needed to restore the model later.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.