How a Neural Network Thinks: Artificial Neurons, Weights, Biases & Forward Pass
Zero-jargon walkthrough of a single Artificial Neuron: multiplying inputs by learned weights, adding a bias threshold, applying an activation function, and drawing a 2D decision boundary!
Even a 100-billion-parameter frontier model is just millions of copies of this exact 2-step operation (weighted sum + bias → non-linear activation) stacked together!
Mastering the single-neuron forward pass makes debugging layer shapes, logits vs. probabilities, and activation saturation completely intuitive.
A single neuron with Sigmoid activation is mathematically identical to Logistic Regression — connecting classic statistics directly to Deep Learning!
Common warmup question: 'What is the geometric role of the bias term in a neuron, and what happens if you remove all activation functions from a 10-layer MLP?'
In a single neuron , what does changing ONLY the bias term do to the decision boundary line?
- Compute a complete single-neuron Forward Pass by hand: followed by
- Explain the intuitive role of weights (feature importance & sign) vs. bias (decision threshold shift)
- Visualize a neuron geometrically as a straight decision boundary splitting feature space into two regions
- Understand why non-linear activations are required so stacked layers don't collapse into a single linear equation
(0.8)(1.0) + (0.5)(2.0) + (-0.4)(1.0) + 0.1 = 1.50.Think of an Artificial Neuron like a fair judge scoring a loan application: multiply each clue (income, credit score, debt) by how much it matters (weights — positive for good clues, negative for red flags), add a baseline strictness bar (bias), and convert the total score into a 0%–100% decision (activation)!
1. Anatomy of an Artificial Neuron
Every artificial neuron performs just two tiny operations:
- Affine (Linear) Combination: Multiply each input by its learned weight , sum them, and add the bias to get .
- Non-Linear Activation: Pass through a squashing or gating curve like ReLU () or Sigmoid () to produce the output .
Live Single-Neuron Forward Pass (x = 1.5)
2. Walking Through a Forward Pass With Real Numbers
Never be intimidated by vector notation — is just multiplying pairs of numbers and adding them up! Watch how (1.0, 2.0, 1.0) transforms step-by-step into 81.8% confidence:
3. Geometric Intuition: One Neuron = One Straight Line
Set : that equation is literally a straight line in 2D (or a flat hyperplane in -D)! Points on one side score (Class 1); points on the other score (Class 0). In Module 2, we'll stack neurons into layers so they can bend space and carve curved shapes!
What happens if you stack 5 linear layers with NO non-linear activation functions between them?
The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.
Only loosely inspired! Biological neurons fire electrical spikes over time with complex chemistry; artificial neurons are clean, differentiable math functions designed for fast GPU matrix multiplication.
Step-by-Step Artificial Neuron Forward Pass
Follow raw inputs through weights, bias addition, and non-linear activation into a probability.
Building Block of Every Modern Neural Architecture
Every Dense layer, Conv kernel, and Transformer FFN is a vectorized grid of artificial neurons computing Wx + b followed by an activation.
import torch
import torch.nn.functional as F
# Single artificial neuron forward pass: z = w^T x + b, a = ReLU(z)
x = torch.tensor([1.5, -0.8, 2.0]) # 3 input features
w = torch.tensor([0.6, -1.2, 0.4]) # learnable weights
b = torch.tensor(-0.5) # learnable bias
pre_activation = torch.dot(w, x) + b # weighted sum + bias
activation = F.relu(pre_activation) # non-linear firing gate
print(f"Pre-activation z = {pre_activation.item():.3f}")
print(f"ReLU output a = {activation.item():.3f}")
# Batched layer of 4 neurons processing a batch of 2 samples (shape: [2, 3] -> [2, 4])
X_batch = torch.randn(2, 3)
W_layer = torch.randn(3, 4) * 0.5
b_layer = torch.zeros(4)
out = F.relu(X_batch @ W_layer + b_layer)
print("Batched layer output shape:", tuple(out.shape))
nn.Linear(in, out).in * out + out (weights + biases), unless bias=False is explicitly passed!w = [2.0, -1.0], bias b = -1.0, and input x = [1.5, 1.0]. What is the pre-activation score z?