Skip to content

Tutorials

Tutorials teach by doing. Each one walks you through a complete, working example from start to finish. You will see real output at every step.

Available tutorials

  • Getting Started — Train a binary classifier on an imbalanced dataset, progressing from vanilla BCE to Smooth-AP with warmup. By the end you will have a working training loop and a visible improvement in AUCPR.
  • Multiclass Classification — Train a 5-class classifier with exponential class imbalance, progressing from CrossEntropyLoss to SoftmaxFocalLoss with per-class alpha to SmoothAPLoss with warmup. Shows correct target format and warmup hook usage for multiclass tasks.

What you need

  • Python 3.10+
  • PyTorch ≥ 2.8
  • scikit-learn (for the demo data)

Install everything:

pip install "imbalanced-losses[demo]"