← TensorFlow & Keras learning pathTensorFlow & Keras · Module 4 of 10
Compiling and training
Train models with compile and fit.
📖 Key ideas
- model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"]).
- model.fit(x, y, epochs=10, batch_size=32, validation_split=0.2).
- History object stores loss and metrics per epoch.
- model.evaluate() tests on held-out data.
- model.predict() makes predictions.
💡 Real-life example: compile chooses the training plan; fit runs the training sessions; evaluate is the final exam.
compile()Sets optimiser, loss, metrics
fit()Trains the model
evaluate()Measures performance on data
predict()Generates predictions