← Writing & notes

FROM THE NOTEBOOK

Deep Learning Algorithms 1: Fundamentals

This document covers the core concepts that form the foundation of all artificial neural networks. We will build from the simplest computational unit, the Perceptron, to the mechanics of training complex, multi-layered networks.

Table of Contents

  1. The Perceptron: The Simplest Neural Network
  2. Multi-Layer Perceptron (MLP): Introducing Depth
  3. The Training Engine: Feedforward and Backpropagation
  4. Activation Functions: Introducing Non-Linearity
  5. Loss Functions: Measuring Error
  6. Optimization: Learning from Error

1. The Perceptron: The Simplest Neural Network

The Perceptron is the original and simplest form of a neural network, conceptualized as a single neuron. It serves as a linear classifier for binary classification tasks.

How it works

  1. Inputs and Weights: It takes a set of binary inputs (x₁, x₂, ...) and multiplies them by a corresponding set of weights (w₁, w₂, ...). These weights signify the importance of each input.
  2. Weighted Sum: It computes the weighted sum of the inputs. A bias term is often added to this sum.
  3. Activation: It applies a simple step function to the sum. If the sum exceeds a certain threshold, the Perceptron "fires" and outputs 1; otherwise, it outputs 0.

Limitations

A single-layer Perceptron is only capable of learning linearly separable patterns. It famously cannot solve the XOR problem, a limitation that highlighted the need for more complex, multi-layered networks.


2. Multi-Layer Perceptron (MLP): Introducing Depth

A Multi-Layer Perceptron (MLP) is a class of feedforward neural network that overcomes the limitations of the single-layer Perceptron. It consists of an input layer, one or more hidden layers, and an output layer.

Key Features


3. The Training Engine: Feedforward and Backpropagation

Feedforward and Backpropagation are the two fundamental processes that allow an MLP to learn from data.

Feedforward Propagation

This is the process of passing input data through the network to get a prediction.

  1. The input data is fed to the input layer.
  2. Each layer of neurons receives inputs from the previous layer, computes a weighted sum, and applies its activation function.
  3. This process continues layer by layer until the output layer produces a final prediction.

Backpropagation (Backward Propagation of Errors)

This is the algorithm used to train the network by adjusting its weights.

  1. Calculate Loss: A loss function is used to calculate the error, which is the difference between the network's prediction and the actual target value.
  2. Compute Gradients: Backpropagation uses the chain rule of calculus to efficiently compute the gradient (the partial derivative) of the loss function with respect to each weight and bias in the network. It starts from the output layer and works its way backward.
  3. Update Weights: An optimizer uses these gradients to update the weights and biases in the direction that minimizes the loss. This is typically done via a method like Gradient Descent.

This two-step cycle of feedforward and backpropagation is repeated for many epochs (passes through the entire dataset) until the network's performance converges.


4. Activation Functions: Introducing Non-Linearity

Activation functions are a critical component of a neural network, applied to the output of each neuron. They introduce the non-linearity that allows the network to learn anything more complex than a simple linear transformation.

Common Activation Functions


5. Loss Functions: Measuring Error

A loss function (or cost function) quantifies how well the model is performing. It calculates a single number representing the difference between the model's predictions and the ground truth labels. The goal of training is to minimize this value.

Common Loss Functions


6. Optimization: Learning from Error

Optimizers are the algorithms that implement the backpropagation process. They take the gradients calculated by backpropagation and use them to update the network's weights and biases in order to minimize the loss function.

Gradient Descent

The foundational optimization algorithm is Gradient Descent. It updates parameters by taking a step in the direction of the negative gradient of the loss function. new_weight = old_weight - learning_rate * gradient

Types of Gradient Descent

Advanced Optimizers

While SGD is the basis for most training, more advanced optimizers have been developed to improve the speed and reliability of convergence.

All writing