Skip to content

Notebooks

You can run Jacobi interactively cell by cell in VS Code, JupyterLab, or Google Colab using the Rust Jupyter kernel (evcxr_jupyter).

Starter notebooks live in notebooks/.

  • 01_quickstart.ipynb covers tensors, autodiff, compiled MLP training, inline SVG plots, and .safetensors saving.
  • 02_vision_cnn.ipynb trains a 2D CNN with imshow image previews and loss curves.
  • 03_transformers_and_export.ipynb trains a Mini GPT, runs compiled generation, saves .safetensors, and exports .onnx.

Running in VS Code

  1. Install the Rust Jupyter kernel once in your terminal, then restart VS Code. The latest evcxr_jupyter requires a recent Rust toolchain, so update stable first.
rustup update stable
rustup component add rust-src
cargo install --locked evcxr_jupyter
evcxr_jupyter --install
  1. Install the official Jupyter extension in VS Code.
  2. Open any file in notebooks/ (such as notebooks/01_quickstart.ipynb).
  3. Click Select Kernel in the top-right corner of the notebook, pick Jupyter Kernel, and choose Rust.
  4. Run the cells top to bottom. The first cell compiles jacobi once for the session (roughly 20 to 40 seconds). Subsequent cells compile in a second or two and run on XLA at native speed.

Running in JupyterLab

With evcxr_jupyter installed, launch JupyterLab as usual and open any .ipynb file.

jupyter lab notebooks/01_quickstart.ipynb

Inline Plots and Tensor Previews

Jacobi implements evcxr_display natively on both Tensor and io::plot::Figure with no extra dependencies.

  • Ending a cell with a Tensor expression displays a compact HTML preview with its shape, dtype, and values.
  • Ending a cell with a Figure (.plot(...), .scatter(...), or .imshow(...)) renders the SVG chart directly inside the cell output.
use jacobi::io::plot::Figure;
use jacobi::prelude::*;

let x = Tensor::linspace(0.0, 6.28, 64);
Figure::new()
    .title("sin(x)")
    .plot(&x, &x.sin(), Some("sin"))
    .unwrap()