DEV Community

Cover image for Plotting Keras training history with Matplotlib
Talles L
Talles L

Posted on

Plotting Keras training history with Matplotlib

import matplotlib.pyplot as plt

def plot_training(history):  
    plt.figure(figsize=(8, 5))  # 8x5 inches

    for key in history.keys():
        plt.plot(history[key], label=key)

    plt.grid(True)
    plt.ylim(0, 1)
    plt.xlabel('Epoch')
    plt.ylabel('Value')
    plt.title('Learning Curve')
    plt.legend()
    plt.show()

training_history = model.fit(...)
plot_history(training_history)
Enter fullscreen mode Exit fullscreen mode

Example:

Top comments (0)