←Resources HubAI & Machine Learning · Grades 6–12 · College

Neural-NetworkVisualizer

Explore how artificial neural networks learn to classify handwritten digits, geometric shapes, and visual patterns through supervised machine learning. Adjust hidden layers and activation functions, observe forward propagation and backpropagation across weights, and evaluate your trained model on custom drawings.

Code Studio · 2nd Window

Full-Screen Interactive Workspace

Pop this visualizer out into an edge-to-edge 2nd window for side-by-side study or classroom projection.

Forward & BackpropInteractive SketchpadPyTorch & TensorFlow
Explore AI / ML Courses →
Interactive Visual Reference · Grades 6–12 & College AI

Understanding Every Neural-Network Term Visually

Every button, chart, and connection inside the visualizer represents a core building block of modern machine learning and deep learning. Use the visual diagrams below to see how raw pixel numbers turn into accurate image classifications.

Input & PixelsWeights & ParamsHidden LayersActivationsForward & SoftmaxLoss & GeneralizationBackprop & Learning RateEpochs & Confusion Matrix
01
Encode PixelsConvert an 8×8 drawing into 64 brightness numbers from 0.0 to 1.0.
02
Forward PassMultiply by weights, apply non-linear activations, and compute Softmax probabilities.
03
Measure ErrorScore prediction accuracy against the true label with Cross-Entropy Loss.
04
BackpropagateSend error gradients backward and nudge weights with Adam or SGD across epochs.
Data & ArchitectureINPUT (64) · Normalized Matrix

Input Layer & Pixel Normalization

Drawing Stroke → Normalized Pixel Grid (0.0–1.0) → Input Layer Neurons1. Raw Drawing0.91.01.00.90.00.10.80.40.00.70.40.00.20.90.00.02. Pixel Values [0–1]x₁ = 0.9x₂ = 1.0x₃ = 0.0x₆₄ = 0.03. Input (64)
xᵢ = pixel_intensity / 2558×8 grid = 64 numerical inputs per sample

Neural networks process numbers rather than raw drawings. When you draw on the Sketchpad or select a dataset image, the image is centered, resized into an 8×8 grid of 64 cells, and scaled to brightness values between 0.0 (empty background) and 1.0 (solid stroke). Each of the 64 numbers feeds directly into one neuron of the Input Layer.

Try It Above: Draw a digit or shape on the Sketchpad and watch the Normalized 8×8 Matrix preview convert your stroke into 64 numerical brightness inputs.
Data & ArchitecturePositive / Negative Weight · params

Synaptic Weights, Biases & Parameters

Excitatory (+w) vs. Inhibitory (−w) Synapses Feeding One Neuronx₁ = 1.0+1.4 (Excite)x₂ = 0.8−1.1 (Suppress)x₃ = 0.6+0.9 (Excite)Bias b = −0.2Σ + bz = 0.86Layer Params(Nᵢₙ × Nₒᵤₜ) + Nₒᵤₜweights + biases
z = Σ(wᵢ · xᵢ) + bGreen lines boost confidence; red lines rule out wrong classes

Every line connecting two neurons carries a learnable multiplier called a weight (w), and each receiving neuron adds an offset called a bias (b). Positive weights (green lines) amplify signals when an expected stroke is present, while negative weights (red lines) suppress signals that belong to competing classes. The params badge counts every trainable weight and bias across all layers.

Try It Above: Increase L1 from 8 to 16 neurons in the toolbar and watch the total params badge grow as new synaptic connections are added.
Data & ArchitectureHIDDEN LAYERS: L1, L2, L3

Hidden Layers & Feature Hierarchy

Hierarchical Feature Composition Across LayersInputPixelsHidden L1Stroke EdgesHidden L2Loops & PartsOutputClass "8"
h⁽ˡ⁾ = f(W⁽ˡ⁾ · h⁽ˡ⁻¹⁾ + b⁽ˡ⁾)Each hidden layer builds higher-level visual abstractions

A Multi-Layer Perceptron (MLP) places one or more hidden layers between the raw input pixels and the final output classes. Early hidden neurons (L1) learn to detect simple local strokes such as horizontal bars or diagonal edges; deeper layers (L2, L3) combine those strokes into loops, corners, and intersections needed to distinguish look-alike digits and shapes.

Try It Above: Compare training Digits (0–9) with 1 small hidden layer of 4 neurons versus 2 hidden layers (L1: 12, L2: 10) to see how representational capacity impacts accuracy.
Forward PassActivation: ReLU | Sigmoid | Tanh

Activation Functions (ReLU, Sigmoid, Tanh)

Interactive Non-Linear Curve Inspector
+10−1zf(z)ReLU GateRange: [0, ∞)z < 0 → 0.0z > 0 → z
f(z) = max(0, z)Zeros out negative inputs; fast gradients for positive signals

Without an activation function, stacking multiple layers mathematically collapses into a single flat linear equation—unable to separate curved or nested visual patterns. Non-linear activation functions let each hidden neuron decide how strongly to fire: ReLU outputs zero for negative sums and passes positive signals unchanged, Sigmoid squashes values smoothly between 0 and 1, and Tanh centers outputs between −1 and +1.

Try It Above: Switch Activation between ReLU, Sigmoid, and Tanh before clicking Train Model to compare how fast each non-linear curve converges.
Forward PassClass Probabilities · Confidence

Forward Propagation & Softmax Confidence

Raw Output Logits → Softmax Normalization → 100% Probability DistributionRaw Logits (z)z₀ = +3.1z₁ = +1.2z₂ = −0.8Softmaxeᶻⁱ / Σ eᶻʲProbabilities (Σ = 100%)Circle85%Square13%Triangle2%
P(class i) = exp(zᵢ) / Σⱼ exp(zⱼ)Exponentiation amplifies the winning class and guarantees 0%–100%

Forward propagation is the left-to-right pass that turns pixel inputs into a prediction. Each layer multiplies inputs by weights, adds biases, and applies its activation until the Output Layer produces raw unscaled scores (logits). The Softmax function exponentiates and normalizes those logits into positive percentages between 0% and 100% that sum to 100%, where the highest percentage becomes the predicted class.

Try It Above: Draw an ambiguous shape (such as an oval between a 0 and an 8) to see Softmax split confidence across two runner-up classes instead of 99% on one.
Loss & OptimizationVal Loss · Test Acc · Cross-Entropy

Cross-Entropy Loss & Generalization (Train vs. Val)

Training Loss vs. Unseen Validation Loss Across Epochs2.30.0Training Epochs (1 → 35)Overfit (Val rises)Train LossVal LossGoal: Low Val LossWorks on unseen data
Loss = −ln(P_true_class)Lower Val Loss means stronger generalization to new drawings

Categorical Cross-Entropy Loss measures how far the model's predicted probabilities are from the true label: assigning 95% confidence to the right class yields near-zero loss, while assigning 5% confidence produces a steep penalty. Plotting Training metrics (examples used to update weights) alongside Validation metrics (held-out unseen examples) verifies whether the network genuinely generalizes rather than memorizing.

Try It Above: Watch the Cross-Entropy Loss chart during training: both the solid Train line and dashed Val line should curve downward toward zero together.
Loss & OptimizationOptimizer · Learning Rate · Live Backprop

Backpropagation, Optimizers (Adam, SGD) & Learning Rate

Gradient Descent Step-Size Simulator
Weight Value (w)LossLR = 0.02Adam vs. SGD:SGD: fixed stepAdam: adaptivemomentum per w
w ← w − η · ∂Loss/∂wWell-tuned steps: smoothly descends straight to lowest loss

Once loss is calculated, Backpropagation applies the calculus chain rule backward from the output layer through every hidden layer to measure each weight's gradient (the direction that increases error). The Optimizer steps in the opposite direction to reduce error: SGD takes uniform gradient steps, while Adam adapts step sizes per parameter using momentum. The Learning Rate controls how large each weight update step is.

Try It Above: Compare SGD with Learning Rate 0.005 (gradual descent) against Adam with Learning Rate 0.02, or test 0.1 to observe unstable overshooting.
EvaluationEpoch 0/35 · Confusion Matrix

Epochs, Mini-Batches & Confusion Matrix

True Labels (Rows) vs. Predicted Labels (Columns) on Unseen Test Data1 Epoch = Full DatasetMini-Batches (16)Repeated for 35 EpochsPredicted Class →Pred 0True 0Pred 3True 3Pred 8True 8181001721118
Accuracy = Diagonal Sum / Total Test SamplesDiagonal cells = correct; off-diagonal = look-alike mix-ups

One Epoch represents one complete pass through the entire training dataset, divided into small mini-batches of 16 images so weights refine dozens of times per epoch. To audit accuracy beyond a single percentage, the Confusion Matrix tab tabulates True labels (rows) against Predicted labels (columns) on unseen test images—highlighting accurate predictions along the green diagonal and specific class mix-ups off the diagonal.

Try It Above: Open the Confusion Matrix tab before training (random guesses scattered everywhere) and again after Epoch 35 (clean diagonal alignment).

Frequently Asked Questions: Neural Networks & Machine Learning

What can students explore in the Neural-Network Visualizer?

Students can build, train, and evaluate multi-layer perceptron (MLP) image classifiers across three datasets—Handwritten Digits (0–9), Geometric Shapes, and Visual Patterns. They can configure hidden layers, neuron counts, activation functions (ReLU, Sigmoid, Tanh), optimizers (Adam, SGD), and learning rates while observing synaptic weights, class probabilities, loss curves, and confusion matrices.

How do forward propagation and backpropagation appear in the network diagram?

Each column represents a layer of neurons from normalized pixel inputs through hidden feature layers to softmax output classes. Positive weights appear as green excitatory connections and negative weights appear as red inhibitory connections, updating across epochs as backpropagation minimizes categorical cross-entropy loss.

What is the difference between ReLU, Sigmoid, and Tanh activation functions?

Activation functions introduce non-linearity so stacked hidden layers can learn curved and composite visual features rather than collapsing into a single linear equation. ReLU outputs zero for negative inputs and passes positive values unchanged for fast gradient flow, Sigmoid squashes values smoothly between 0 and 1, and Tanh centers activations between −1 and +1.

Why does the monitor plot both Training and Validation Loss?

Training metrics measure performance on images the network actively studies to update its weights, while Validation metrics evaluate performance on held-out unseen test images. When both curves drop together, the model generalizes to new drawings; if Validation Loss rises while Training Loss drops, the model is overfitting (memorizing training examples).

Can students test their trained model on their own drawings?

Yes. The Interactive Test Sketchpad centers and normalizes hand-drawn digits, shapes, and patterns into an 8×8 pixel intensity matrix matching the 64-neuron input layer, computing forward-pass neuron activations and softmax class confidence scores immediately.

How do students read the Confusion Matrix tab?

The Confusion Matrix compares True image classes (rows) against Predicted classes (columns) across unseen test samples. Numbers along the green diagonal represent accurate classifications, while off-diagonal cells pinpoint specific look-alike confusions—such as mistaking a handwritten 3 for an 8.

Which machine learning frameworks are generated in Production Code?

As students customize hidden layers, activations, optimizers, and learning rates, the Production Code inspector generates equivalent, runnable model definitions and training loops in TensorFlow.js, TensorFlow / Keras (Python), and PyTorch (nn.Module).

Can teachers use this AI & ML visualizer in classrooms without logins?

Yes. Like all Coders Class educational tools, the Neural-Network Visualizer runs directly in the browser with zero logins, installations, or student data collection, making it ready for smart board demonstrations and Chromebook or laptop lab sessions.

How does Optimal Training compare against custom student hyperparameters?

The visualizer starts in an untrained baseline state so students can witness random initial predictions before training. Students can train their own custom proposed architecture and then click Optimal Training to run a tuned multi-layer benchmark side-by-side, comparing validation accuracy, cross-entropy loss curves, and sketch predictions directly.

One-Time PurchaseWorkbooks Courseware

Video Lectures with a Built-In Workbook Guide

Engineer-led video lectures paired with a built-in interactive workbook, structured sections, practice problem sets, and in-depth instruction.

Chapter-Indexed LecturesBuilt-In Study WorkbookSection Practice ProblemsIn-Depth Instruction
Explore WorkbooksExplore Live Courses
Continue Exploring Free CS Tools

Interactive Visualizers & Curriculum Guides

View All Resources Hub
Grades 6–12 · AP CSP

Visual Code Blocks & Translator

Snap together variables, conditions, and loops with live translation into JavaScript, Python 3, and Java 21 plus control flow diagrams.

AP CS A · Foundations

Basic Data Structures

Animate contiguous arrays, LIFO stacks, FIFO queues, key-value hashmaps, linked list pointers, and binary search trees alongside Big-O complexity.

AP CS A · College DSA

Advanced Data Structures

Explore 2D matrices, min/max heaps, hashsets, doubly linked deques, prefix tries, self-balancing AVL trees, BFS/DFS graphs, and union-find.

Students · Parents · Teachers

CS & AI Learning Guide

Explore AP Computer Science standards alignment, classroom smart board guidance, and multi-language pathways from blocks to systems engineering.

Curriculum aligned with AI & Machine Learning Foundations (Grades 6–12 & College).
Browse Live CoursesBook Free 1-on-1 Trial Session
CODERS CLASS

Empowering the next generation of engineers through high-impact, professional-grade coding education and expert mentorship.

PLATFORM

  • Meet the Team
  • Course Catalog
  • Workbooks
  • Class Schedule
  • Learning Resources
  • Games Hub

COMPANY

  • Our Mission
  • Careers
  • Privacy Policy
  • Terms of Service

CONNECT

SUPPORTsupport@codersclass.com

© 2026 CODERS CLASS LLC. ALL RIGHTS RESERVED.

Coders Class Logo
CODERS CLASS
  • HOME
  • COURSESWORKBOOKSPATENTS PROGRAM
  • SCHEDULE
  • RESOURCES HUBLEARNING GUIDEGAMES HUBBLOGS
    CODE STUDIOCODE LAB
  • OUTREACH
  • EMAILinfo@codersclass.com
    CALL OR TEXT FOR INFO(310) 359-1617
  • LOGIN
Dataset:
Hidden Layers:
L1:6
Network Graph Architecture
Positive Weight Negative Weight
Multi-Layer Perceptron · Supervised Classification
neural_classifier.ts
JS · Browser
1import * as tf from '@tensorflow/tfjs';
2 
3// 1. Construct Browser Neural Network
4const model = tf.sequential({
5 layers: [
6 tf.layers.dense({ units: 6, activation: 'sigmoid', inputShape: [64] }),
7 tf.layers.dense({ units: 10, activation: 'softmax' })
8 ]
9});
10 
11// 2. Compile Model with Hardware Acceleration (WebGL / WebGPU / CPU)
12model.compile({
13 optimizer: tf.train.sgd(0.005),
14 loss: 'categoricalCrossentropy',
15 metrics: ['accuracy']
16});
17 
18// 3. Train in the Browser (35 Epochs)
19async function trainInBrowser(xTensor, yTensor, onEpochEnd) {
20 return await model.fit(xTensor, yTensor, {
21 epochs: 35,
22 batchSize: 16,
23 validationSplit: 0.15,
24 callbacks: {
25 onEpochEnd: (epoch, logs) => {
26 onEpochEnd({
27 epoch: epoch + 1,
28 loss: logs.loss,
29 acc: logs.acc,
30 valLoss: logs.val_loss,
31 valAcc: logs.val_acc
32 });
33 }
34 }
35 });
36}
37 
38// 4. Real-time Inference on Drawn Pixels
39function predict(flatPixels) {
40 return tf.tidy(() => {
41 const input = tf.tensor2d([flatPixels], [1, 64]);
42 const probs = model.predict(input);
43 const data = probs.dataSync();
44 const bestIndex = probs.argMax(-1).dataSync()[0];
45 return { bestIndex, probabilities: Array.from(data) };
46 });
47}
48 

Interactive Test Sketchpad

Draw a digit (0–9) directly on the pad or click a test sample

Model PredictionUntrained
Confidence—
Normalized 8×8 input vector fed into 64 input neurons. Click Train Model to teach the network.
Output Class Probabilities (Softmax)
0
12%
1
14%
2
6%
3
6%
4
9%
5
7%
6
15%
7
15%
8
6%
9
10%
Unseen Test Samples (Click to Evaluate)

Loss & Accuracy Monitor

Real-time training convergence vs. unseen validation performance

460 params
Epoch0 / 35
Val Loss—
Test Acc—
Cross-Entropy Loss
TrainVal
Classification Accuracy (%)
TrainVal