Files
burn/examples/simple-regression
Charles23R 4e4c0a564c Clean learning api (#4283)
* clean up types traits, remove paradigm trait, improve learner

* code quality

* book

* doc

* error in doc

* revert TrainStep rename and remove paradigm components

* trainstep refactor with assoc types

* fix docs

* fix warning

* comment

* remove evaluator step
2026-01-12 08:30:44 -05:00
..
2025-05-12 15:56:00 -04:00
2026-01-12 08:30:44 -05:00
2025-10-20 16:22:32 -04:00

Regression

The example shows you how to:

  • Define a custom dataset for regression problems. We implement the California Housing Dataset from HuggingFace hub. The dataset is also available as part of toy regression datasets in sklearndatasets.
  • Create a data pipeline from a raw dataset to a batched fast DataLoader with min-max feature scaling.
  • Define a Simple NN model for regression using Burn Modules.

Note


This example makes use of the HuggingFace datasets library to download the datasets. Make sure you have Python installed on your computer.

The example can be run like so:

git clone https://github.com/tracel-ai/burn.git
cd burn
# Use the --release flag to really speed up training.
echo "Using ndarray backend"
cargo run --example regression --release --features ndarray                # CPU NdArray Backend - f32 - single thread
cargo run --example regression --release --features ndarray-blas-openblas  # CPU NdArray Backend - f32 - blas with openblas
cargo run --example regression --release --features ndarray-blas-netlib    # CPU NdArray Backend - f32 - blas with netlib
echo "Using tch backend"
export TORCH_CUDA_VERSION=cu128                                            # Set the cuda version
cargo run --example regression --release --features tch-gpu                # GPU Tch Backend - f32
cargo run --example regression --release --features tch-cpu                # CPU Tch Backend - f32
echo "Using wgpu backend"
cargo run --example regression --release --features wgpu