Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Neural Networks

1. Introduction to Neural Networks

Neural Networks are non-linear statistical models used for both regression and classification. They are inspired by biological neurons and consist of interconnected processing units (neurons) organized into layers.


2. The Artificial Neuron (Perceptron)

A single neuron computes a weighted sum of its inputs, adds a bias, and applies a non-linear activation function.

Mathematical Formulation

For a neuron with input vector x=[x1,x2,…,xd]⊤\mathbf{x} = [x_1, x_2, \dots, x_d]^\top:

  1. Linear Combination:

    z=∑j=1dwjxj+b=w⊤x+bz = \sum_{j=1}^{d} w_j x_j + b = \mathbf{w}^\top \mathbf{x} + b
  2. Non-linear Activation:

    a=σ(z)a = \sigma(z)

    where w\mathbf{w} is the weight vector, bb is the bias, and σ(⋅)\sigma(\cdot) is the activation function.

Common Activation Functions

Activation functions introduce non-linearity, allowing the network to approximate complex functions.


3. Multilayer Perceptrons (MLP)

In a feedforward network, neurons are arranged in layers where the output of one layer becomes the input of the next.

Forward Propagation

For a network with LL layers, let a(l)a^{(l)} be the activation of layer ll:

z(l)=W(l)a(l−1)+b(l)z^{(l)} = W^{(l)} a^{(l-1)} + b^{(l)}

a(l)=σ(z(l))a^{(l)} = \sigma(z^{(l)})

where W(l)W^{(l)} is the weight matrix for layer ll and a(0)=xa^{(0)} = \mathbf{x}.


4. Training and Loss Functions

To train the network, we define a cost function J(θ)J(\theta) that measures the discrepancy between the prediction y^\hat{y} and the ground truth yy.


5. Backpropagation and Optimization

Optimization is performed using Gradient Descent to minimize the loss function by updating weights and biases:

w←w−η∂J∂ww \leftarrow w - \eta \frac{\partial J}{\partial w}

The Chain Rule

Backpropagation uses the chain rule to compute the gradient of the loss with respect to each parameter by moving backward through the network. For a weight wij(l)w_{ij}^{(l)} in layer ll:

∂J∂wij(l)=∂J∂zi(l)⋅∂zi(l)∂wij(l)\frac{\partial J}{\partial w_{ij}^{(l)}} = \frac{\partial J}{\partial z_i^{(l)}} \cdot \frac{\partial z_i^{(l)}}{\partial w_{ij}^{(l)}}

6. Feature Learning

A key advantage of Neural Networks over traditional methods (like Decision Trees) is their ability to learn hierarchical representations.

In tasks like handwritten digit classification (28×2828 \times 28 pixels), hidden units act as feature detectors. Visualizing the weight vectors wj\mathbf{w}_j as images often reveals that the network has learned to respond strongly to specific strokes or orientations.

PropertyNeural NetworksDecision Trees
Feature ConstructionLearned automatically via hidden layers.Manual feature engineering or axis-aligned splits.
BoundariesSmooth and non-linear.Piecewise constant (box-like).
ScalabilityHigh (with GPU/Big Data).Becomes complex/unstable with very high dimensionality.