Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Your First Model

The canonical end-to-end example in the workspace today is teeny-vision’s LeNet-5 over MNIST:

use teeny_vision::mnist::mnist_lenet5;

let model = mnist_lenet5::<f32>();

That model is used in two different ways elsewhere in the workspace, both worth reading as reference implementations:

  • Training/inference example: models/teeny-vision/examples/mnist.rs — a full, runnable example (cargo run --example mnist, with TEENYC_PATH set — see Installation).
  • Ahead-of-time kernel compilation: utilities/teeny-cli/src/main.rs — traces the model with a symbolic input and AOT-compiles its kernels via teeny_cli::aot_compile.

The shape of a model

Models are built from teeny-core’s nn layer types, implementing the Layer trait. A traced model produces a symbolic computational graph (SymTensor in, Graph out) — see Tensors & the Computational Graph and Compilation Flow for what happens to that graph next.

TODO: walk through building a small model from scratch (not just pointing at the existing LeNet-5 example) once the nn layer API stabilizes enough to commit to in a book.