Stage 01
6 min read
Lesson 5 of 7

Neural Networks Explained

Understand the core architecture of artificial neural networks: artificial neurons, weights, biases, activation functions, and multi-layer computation.

Stage progress71% complete

Neural Networks Explained

Artificial Neural Networks (ANNs) are the foundational architecture behind modern deep learning and generative AI.

Inspired loosely by biological brains, neural networks are collections of interconnected computational nodes (neurons) organized in layers. They are capable of learning complex, non-linear relationships that traditional statistical models struggle to capture.


Why does this matter?

Classical machine learning algorithms (like linear regression or decision trees) work well on structured tabular data with explicit features. However, they struggle on complex unstructured problems:

  • Recognizing a face from raw pixel grids
  • Understanding the nuanced grammar and context of natural language
  • Transcribing conversational audio in noisy environments

Neural networks excel at these tasks because their layered structure automatically learns hierarchical representations of data.


The Biological Inspiration vs Artificial Reality

The human brain consists of billions of biological neurons connected by synapses. When electrical and chemical inputs reach a certain threshold, the neuron "fires," transmitting a signal to downstream neurons.

An artificial neuron (or perceptron) is a mathematical simplification of this biological process:

Inputs (x) ────► [ Multiply by Weights (w) ] ────► [ Sum + Bias (b) ] ────► [ Activation Function ] ────► Output (y)
  1. It receives numerical inputs.
  2. It scales them based on their importance (weights).
  3. It adds an offset to adjust baseline sensitivity (bias).
  4. It passes the sum through a mathematical threshold (activation function) to produce an output.

The Anatomy of an Artificial Neuron

Let's break down each element of a single neuron using an intuitive real-world scenario.

Imagine you are deciding whether to attend an outdoor tech conference this weekend. Your decision depends on three factors (inputs):

  • $x_1$: Is the weather good? (1 for yes, 0 for no)
  • $x_2$: Are your friends attending? (1 for yes, 0 for no)
  • $x_3$: Is the ticket expensive? (1 for yes, 0 for no)

1. Weights: How much each input matters

Not all factors carry equal weight to you.

  • You might care deeply about weather ($w_1 = +5$).
  • You care moderately about friends attending ($w_2 = +2$).
  • You strongly dislike expensive tickets ($w_3 = -4$).

A weight is a multiplier that determines the influence and direction of an input feature. Positive weights promote a higher output; negative weights suppress it.

2. Bias: The baseline threshold

Suppose you are naturally an outgoing person who loves events. Even if the factors aren't perfect, your default tendency is to go. Conversely, if you prefer staying home, you need overwhelming positive reasons to attend.

A bias is a constant value added to the weighted sum. It shifts the activation threshold up or down independently of the inputs.

3. The Weighted Sum

The neuron combines these values:

$$\text{Sum} = (x_1 \cdot w_1) + (x_2 \cdot w_2) + (x_3 \cdot w_3) + \text{bias}$$

4. The Activation Function: Deciding the Output

If the weighted sum is a raw number like 7.3 or -2.1, how do we convert it into a meaningful decision or probability?

An Activation Function introduces non-linearity and maps the weighted sum to an output range:

  • Sigmoid: Compresses any number into a smooth range between 0.0 and 1.0 (ideal for probabilities).
  • ReLU (Rectified Linear Unit): Outputs 0 if the input is negative, and the input itself if positive ($f(z) = \max(0, z)$). ReLU is widely used in modern hidden layers because it is computationally efficient and avoids training slowdowns.

Organizing Neurons into Layers

A single neuron can only solve simple, linear boundary problems. To solve complex problems, we connect hundreds, thousands, or billions of neurons into layers:

Input Layer          Hidden Layer 1         Hidden Layer 2         Output Layer
   (Features)         (Feature Combos)       (Abstract Concepts)     (Prediction)

   ○ (x₁) ───────────────► ○ ─────────────────────► ○ ──────────────────► ○ (Output)
   ○ (x₂) ───────────────► ○ ─────────────────────► ○
   ○ (x₃) ───────────────► ○ ─────────────────────► ○
  1. Input Layer: Receives raw features (e.g., pixel intensities, audio frequencies, sensor values). It does no mathematical transformation.
  2. Hidden Layers: Intermediate layers situated between the inputs and outputs. They extract increasingly abstract features.
  3. Output Layer: Produces the final prediction (e.g., class probabilities for 10 object types, or a single continuous number).

How the Network Computes: Forward Propagation

The process of calculating predictions from inputs to outputs is called Forward Propagation (or the Forward Pass):

  1. Raw input values are fed into the input layer.
  2. Every neuron in the first hidden layer calculates its weighted sum and applies its activation function.
  3. Those outputs become the inputs for the next layer.
  4. The process cascades forward until the output layer generates the final prediction.

How the Network Learns: The Big Picture

How do the weights and biases get their correct values in the first place? They start as random numbers.

Learning happens in three recurring steps:

  1. Forward Pass: The network makes a prediction with its current weights.
  2. Loss Calculation: A loss function measures how far the prediction is from the actual truth.
  3. Backpropagation & Optimization: The error signal is propagated backwards through the network. An optimization algorithm adjusts every weight and bias slightly to decrease the error.

Over millions of training examples, the weights gradually converge to values that accurately solve the problem.


Why Multiple Neurons Work Together

A single neuron draws a single straight boundary line across a dataset.

When you combine multiple neurons across layers:

  • Layer 1 can detect basic straight edges.
  • Layer 2 can combine edges into shapes (corners, circles).
  • Layer 3 can combine shapes into complex objects (eyes, wheels, text glyphs).

This hierarchy of feature learning is what gives neural networks their immense expressive power.


Common Misconceptions

  • Misconception: Artificial neural networks accurately simulate the human brain. Reality: ANNs are loosely inspired by neuroscience, but they are primarily mathematical matrix-multiplication pipelines optimized using statistical calculus.
  • Misconception: More neurons always make a model smarter. Reality: Increasing neurons without adequate training data, proper regularization, and clean architectures leads directly to overfitting and high inference costs.

Key idea

An artificial neuron calculates a weighted sum of its inputs, adds a bias, and passes the result through an activation function. Connecting multiple layers of neurons allows the network to learn intricate, non-linear patterns that simple linear models cannot represent.