Skip to content
Phuc's Blog
Go back

What is a Neural Network?

Edit page
📌Series:Artificial Intelligent
Part 1 of 6
View all articles in this series

This blog will briefly introduce the core concepts of Neural Networks.

What is a Neural Network?

Table of contents

Open Table of contents

What is the Neural Network?

On the surface, a machine recognizing handwritten digits seems not an impressive task at all. I bet you can tell that these are all images of the digit three:

Handwritten Digit Three Samples


The Structure of a Neural Network

An Artificial Neural Network (ANN) is composed of interconnected units called neurons (or nodes) organized into distinct layers:

Complete Multilayer Neural Network Architecture Figure 1: A multilayer neural network with 784 input neurons, two hidden layers of 16 neurons each, and 10 output neurons (Inspired by 3Blue1Brown).

1. Neurons & Activations


2. The Three Types of Layers

  1. Input Layer:
    • Receives raw data from the outside world.
    • For our 28x28 pixel digit image, the input layer consists of 784 neurons (28 x 28 = 784), where each neuron’s activation corresponds to the brightness of a single pixel.

Input Layer — 28×28 pixel brightness values fed into 784 neurons Each pixel’s brightness (0.0 = black, 1.0 = white) becomes one neuron’s activation in the input layer.

  1. Hidden Layers:
    • Located between the input and output layers.
    • These layers break down complex tasks into sub-patterns hierarchically:
      • Layer 1: Detects small, simple line segments and edges.
      • Layer 2: Combines edges into sub-components like loops, strokes, or arcs (e.g., the top loop of a 3).

Hierarchical Feature Detection in Hidden Layers Figure 2: Hidden layers assemble low-level features (edges & lines) into high-level shapes (loops & components).

  1. Output Layer:
    • Provides the final answer.
    • Consists of 10 neurons representing the digits 0 through 9. The neuron with the highest activation score is the network’s final prediction!

Output Layer — network predicts digit 9 with highest activation The output layer lights up neuron “9” — the network’s confident prediction for this handwritten digit.


3. How Neurons Connect: Weights & Biases

Information flows through connections between neurons:

Weights and Biases Illustration Weights dictate the strength and sign of connections between neurons, while biases tune their activation thresholds.


How a Neuron Computes its Output

Each neuron calculates a weighted sum of its inputs plus a bias:

z=(w1x1+w2x2+⋯+wnxn)+bz = (w_1 x_1 + w_2 x_2 + \dots + w_n x_n) + b

Then, it passes this result through an activation function (such as Sigmoid or ReLU) to compress the output into a normalized range (0.0 to 1.0) and introduce non-linearity.

The Sigmoid Activation Function (σ\sigma)

The Sigmoid function is a mathematical function defined as:

σ(x)=11+e−x\sigma(x) = \frac{1}{1 + e^{-x}}

The Sigmoid Activation Function Plot The Sigmoid S-curve squashes raw weighted sums into valid activation scores between 0 and 1.

Vectorized Activation Equation Figure 3: Vectorized layer equation a(1)=σ(Wa(0)+b)a^{(1)} = \sigma(W a^{(0)} + b) representing all weights, activations, and biases across a layer.

Note

Layers break big problems into bite-size pieces.


How Information Passes Between Layers

Information in a neural network flows sequentially forward from layer to layer (Forward Propagation):

a(L)=σ(W(L)a(L−1)+b(L))a^{(L)} = \sigma \left( W^{(L)} a^{(L-1)} + b^{(L)} \right)

Where W(L)W^{(L)} is the weight matrix, b(L)b^{(L)} is the bias vector, and σ\sigma is the activation function.

Information Flow Between Layers Figure 4: How activations flow from layer L−1L-1 through weighted sum and activation function σ\sigma to produce activations for layer LL.


How Neural Networks Learn 🎯

A brand-new neural network starts with completely random weights and biases—meaning its initial guesses are pure garbage!

Learning happens through a 3-step loop:

  1. Forward Propagation: Pass the input image through the network to compute a prediction.
  2. Loss Calculation: Compare the prediction with the true label to calculate the Cost / Loss (how wrong the network was).
  3. Backpropagation & Optimization: Use gradient descent to tweak every weight and bias slightly to reduce the error on the next try.

Repeat this process over thousands of training examples, and the network gradually learns to recognize digits with remarkable accuracy!


Edit page
Share this post:

Previous Post
Backpropagation Calculus
Next Post
Introduction to Parallel Programming

Comments