Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Trace data through the computational graph from input tensors to output activations via vectorized matrix multiplications.
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Activations of previous layer (Batch x In) | Features from earlier stage | |
| Weights (In x Out) | Transformation matrix | |
| Broadcasted bias vector | Row-wise added offset |
Batch of 2 samples passed through layer: A = [[1, 2], [3, 4]], W = [[1], [1]], b = 0.
Result: Output activations: [[3], [7]]
Pack input instances into tensor of shape (Batch Size, Features).
Compute GPU-accelerated matrix product Z = X * W + b.
Apply element-wise activation function A = ReLU(Z).
Chain intermediate activations until output head produces logits.
Problem: Running facial recognition on a battery-powered security camera in 10 milliseconds.
Solution: Quantized INT8 forward propagation executes fast matrix multiplications without backpropagation.
Interactive activity component
Implement a 2-layer forward propagation pass by hand using matrix operations.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install numpy1 import numpy as np
import numpy as np β NumPy for matrix operations
1 # Input: Batch of 2 samples, 3 features each (shape: 2x3) 2 X = np.array([[1.0, 2.0, 3.0], [0.5, -1.0, 2.0]]) 3 4 # Layer 1 Weights (3x4) and Biases (4,) 5 W1 = np.array([[0.2, -0.1, 0.5, 0.1], [0.4, 0.3, -0.2, 0.5], [-0.1, 0.2, 0.1, -0.3]]) 6 b1 = np.array([0.1, 0.1, 0.0, -0.1]) 7 8 # Layer 1 Forward Pass: Z1 = X @ W1 + b1, A1 = ReLU(Z1) 9 Z1 = np.dot(X, W1) + b1 10 A1 = np.maximum(0, Z1) # ReLU 11 print("Layer 1 Activations (shape 2x4):\n", A1.round(3)) 12 13 # Layer 2 (Output Head): Weights (4x1) and Bias (1,) 14 W2 = np.array([[0.5], [-0.3], [0.8], [0.2]]) 15 b2 = np.array([0.0]) 16 Z2 = np.dot(A1, W2) + b2 17 print("\nFinal Output Predictions (shape 2x1):\n", Z2.round(3))
# Input: Batch of 2 samples, 3 features each (shape: 2x3)
Input batch
X = np.array([[1.0, 2.0, 3.0], [0.5, -1.0, 2.0]])
2 instances
# Layer 1 Weights (3x4) and Biases (4,)
Layer 1
W1 = np.array([[0.2, -0.1, 0.5, 0.1], [0.4, 0.3, -0.2, 0.5], [-0.1, 0.2, 0.1, -0.3]])
W1 matrix
b1 = np.array([0.1, 0.1, 0.0, -0.1])
b1 bias
# Layer 1 Forward Pass: Z1 = X @ W1 + b1, A1 = ReLU(Z1)
Layer 1 computation
Z1 = np.dot(X, W1) + b1
Linear combination
A1 = np.maximum(0, Z1) # ReLU
Activation
print("Layer 1 Activations (shape 2x4):\n", A1.round(3))
Show activations
# Layer 2 (Output Head): Weights (4x1) and Bias (1,)
Layer 2
W2 = np.array([[0.5], [-0.3], [0.8], [0.2]])
W2 matrix
b2 = np.array([0.0])
b2 bias
Z2 = np.dot(A1, W2) + b2
Final linear score
print("\nFinal Output Predictions (shape 2x1):\n", Z2.round(3))
Print predictions
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Manual Forward Pass in Pure NumPy 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install numpy 8 9 # Step 2: Import libraries 10 import numpy as np 11 12 # Step 3: Run Demonstration 13 # Input: Batch of 2 samples, 3 features each (shape: 2x3) 14 X = np.array([[1.0, 2.0, 3.0], [0.5, -1.0, 2.0]]) 15 16 # Layer 1 Weights (3x4) and Biases (4,) 17 W1 = np.array([[0.2, -0.1, 0.5, 0.1], [0.4, 0.3, -0.2, 0.5], [-0.1, 0.2, 0.1, -0.3]]) 18 b1 = np.array([0.1, 0.1, 0.0, -0.1]) 19 20 # Layer 1 Forward Pass: Z1 = X @ W1 + b1, A1 = ReLU(Z1) 21 Z1 = np.dot(X, W1) + b1 22 A1 = np.maximum(0, Z1) # ReLU 23 print("Layer 1 Activations (shape 2x4):\n", A1.round(3)) 24 25 # Layer 2 (Output Head): Weights (4x1) and Bias (1,) 26 W2 = np.array([[0.5], [-0.3], [0.8], [0.2]]) 27 b2 = np.array([0.0]) 28 Z2 = np.dot(A1, W2) + b2 29 print("\nFinal Output Predictions (shape 2x1):\n", Z2.round(3))
Maps batch of (2, 3) through W1 (3, 4) into hidden space (2, 4).
ReLU clamps negative values to 0.0.
Projects (2, 4) through W2 (4, 1) to produce scalar outputs for each instance in the batch.
Batch of 2 samples with 3 features
Layer 1 Activations (shape 2x4): [[0.8 1.2 0.4 0.1] [0.0 0.2 0.65 0. ]] Final Output Predictions (shape 2x1): [[0.38 ] [0.46 ]]
Vectorized forward propagation handles entire batches in parallel without any Python for-loops.
CNN, MNIST dataset, backpropagation, loss functions, and optimization.
Test your understanding with these questions. Remember, this is for learning, not examination!