High-level PyTorch training · vision / tabular / text / collab · verified against fastai 2.8 (2026)

fastai cheat sheet

fastai is a layered high-level API over PyTorch: a few lines take you from data to a trained, state-of-the-art model. The pattern is always DataLoaders → Learner → fine_tune, with best-practice defaults (one-cycle schedule, discriminative LRs, transfer learning) baked in. Applications share the API: vision, tabular, text, and collaborative filtering. This sheet targets fastai 2.8 (Python 3.10+).

core: DataLoaders & Learner DataBlock (flexible data) train & schedule inference & export interpret & extend gotcha most common

Verified 2026-08-24 against the official docs at docs.fast.ai (fastai 2.8.x). Built on PyTorch; the fastbook & course provide the canonical examples. Application modules: fastai.vision.all, fastai.tabular.all, fastai.text.all, fastai.collab.

Outline

Fastest path: an application DataLoaders factory + an application Learner + fine_tune. Reach for DataBlock when the factory methods aren't flexible enough.

Start

  1. 1 · Install & the 4-line model
  2. 2 · Application learners

Data

  1. 3 · DataBlock
  2. 4 · Item vs batch transforms

Train

  1. 5 · fine_tune / fit_one_cycle
  2. 6 · LR finder & freezing
  3. 7 · Metrics & callbacks

Use it

  1. 8 · Predict & export
  2. 9 · Interpretation
  3. 10 · Gotchas
  4. Worth memorizing

Start

A trained image classifier in four lines.

1Install & the 4-line model2.8
2Application learnersone API, many domains

Data (the DataBlock)

When factory methods aren't enough, the DataBlock describes your data declaratively.

3DataBlockflexible pipeline
4Item vs batch transformsCPU vs GPU

Train

The one-cycle policy and transfer-learning schedule are the defaults.

5fine_tune / fit_one_cyclethe schedule
6LR finder & freezingtuning
7Metrics & callbackscustomize the loop

Use the Model

Predict, export for production, and understand mistakes.

8Predict & exportdeploy
9Interpretationunderstand errors
!Common gotchasread before shipping

Worth memorizing

DataLoaders → Learner → fine_tunethe universal fastai workflow across vision/tabular/text/collab
factory methods for speedImageDataLoaders.from_folder/from_df; DataBlock when you need control
item_tfms (CPU) vs batch_tfms (GPU)resize per item, augment per batch
fine_tune for transfer learningfreezes head first, then unfreezes with discriminative LRs
lr_find before choosing lrpick from the steepest-descent region
slice() = discriminative LRslow LR for early layers, high for late
export for productionsaves model + pipeline; load_learner to reload anywhere
plot_top_losses finds label errorsthe fastest data-cleaning trick
to_fp16() for free speedmixed precision in one call