MNIST Neural Network Digit Recognition
Tuesday, November 19, 2024
demos
mnist
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A complete neural network implementation running entirely in React Native. Draw a digit on the canvas and watch the network predict the number in real-time with animated visualizations.
What's This About?
This demo implements a fully functional neural network for handwritten digit recognition (MNIST), running entirely on the UI thread using Reanimated worklets. Draw any digit 0-9 and see live predictions along with a visualization of the network's internal state.
Technical Implementation
A remarkable feat of React Native animation:
Pure JavaScript Neural Network: Forward propagation implemented in worklets
Pre-trained Weights: Model weights loaded from JSON for instant predictions
Real-time Inference: Predictions update as you draw, running on UI thread
Network Visualization: Animated display of neuron activations
28x28 Grid Input: Standard MNIST input size with touch drawing
Architecture
The neural network consists of:
Input Layer: 784 neurons (28x28 pixel grid)
Hidden Layer: Dense layer with pre-trained weights
Output Layer: 10 neurons (digits 0-9)
Activation: ReLU/Softmax for predictions
How It Works
Draw on the grid canvas to create a digit
The drawing is converted to a 28x28 grayscale matrix
Matrix is fed through the neural network in a worklet
Predictions update in real-time as activations propagate
Output probabilities are displayed for all 10 digits
Clear button resets the canvas for a new drawing
Usage
import { Mnist } from './mnist';
// Self-contained component with drawing grid and predictions
<Mnist />;
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Mnist
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback