This repository contains a simple (newbie) implementation an MLP in Rust built from scratch with minimum dependencies (only rand
crate for the library code). Originally, this project emerged as a requirement for the PV021 course at FI MUNI. The task involved coding a neural network from the ground up to achieve an 88% accuracy on the Fashion MNIST dataset, a goal that has been successfully met.
The code has been made modular so that the network library can be used for other tasks as well.
src/
contains the library codeexamples/
contains code of how to use the library (e.g. training on MNIST)
- Download the fashion MNIST dataset from here and extract it at the root of the repository (you should have
data
folder next tosrc
andexamples
). - Run the training with
cargo run --example mnist --release
- It seems that the functional programming approach is not the best fit for a lot of immutable data structures, especially when they are nested.
- The primary emphasis was on achieving speed. Notably, a single epoch of training on the Fashion MNIST dataset takes approximately 2 seconds on an M1 MacBook Air.
- Multi-threading helps a lot, but strangely only up to 32 threads, after which it gets slower again (probably due to communication overhead).