Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexErrant committed Nov 15, 2023
1 parent 469e270 commit 939f3d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/train-web/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ For example, run `cargo install --version 0.2.88 wasm-bindgen-cli --force`. The

Install [PNPM](https://pnpm.io/).

The [`postinstall.sh`](./web/postinstall.sh) script expects the mnist database to be at `~/.cache/burn-dataset/mnist.db`. Running `guide` will generate this file. Alternatively, you can download it from [Hugging Face](https://huggingface.co/datasets/mnist).
Install [cargo-watch](https://crates.io/crates/cargo-watch).

The [`postinstall.sh`](./web/postinstall.sh) script expects the mnist database to be at `~/.cache/burn-dataset/mnist.db`. Running `burn/examples/guide` will generate this file. Alternatively, you can download it from [Hugging Face](https://huggingface.co/datasets/mnist).

Then in separate terminals:

Expand Down
2 changes: 2 additions & 0 deletions examples/train-web/train/src/mnist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ impl Dataset<MNISTItem> for MNISTDataset {
impl MNISTDataset {
/// Creates a new dataset.
pub fn new(labels: &[u8], images: &[u8], lengths: &[u16]) -> Self {
// Decoding is here.
// Encoding is done at `examples/train-web/web/src/train.ts`.
debug_assert!(labels.len() == lengths.len());
let mut start = 0 as usize;
let raws = labels
Expand Down
6 changes: 6 additions & 0 deletions examples/train-web/web/src/train.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export function setupTrain(element: HTMLInputElement) {
}

async function loadSqliteAndRun(ab: ArrayBuffer) {
// Images are an array of arrays.
// We can't send an array of arrays to Wasm.
// So instead we merge images into a single large array and
// use another array, `lengths`, to keep track of the image size.
// Encoding is done here.
// Decoding is done at `burn/examples/train-web/train/src/mnist.rs`.
const trainImages: Uint8Array[] = []
const trainLabels: number[] = []
const trainLengths: number[] = []
Expand Down

0 comments on commit 939f3d0

Please sign in to comment.