Search Knowledge

© 2026 LIBREUNI PROJECT

Machine Learning / Deep Learning

Neural Networks Foundations

Neural Networks Foundations

Artificial Neural Networks (ANNs) are computational models inspired by biological neural networks, structured as layers of interconnected nodes.

The Perceptron

The Perceptron is the simplest ANN architecture, computing a weighted sum of inputs plus a bias, and applying a step function:

y^=step(z)=step(wTx+b)\hat{y} = \text{step}(z) = \text{step}(w^T x + b)

A single Perceptron is a linear classifier, meaning it cannot solve non-linearly separable problems (like the XOR problem).

Multilayer Perceptron (MLP)

An MLP consists of an input layer, one or more hidden layers, and an output layer. Hidden layers allow the model to learn non-linear representations.

Forward Propagation

For layer ll, the activations a(l)a^{(l)} are computed using the weight matrix W(l)W^{(l)} and bias vector b(l)b^{(l)}:

z(l)=W(l)a(l1)+b(l)z^{(l)} = W^{(l)} a^{(l-1)} + b^{(l)} a(l)=ϕ(z(l))a^{(l)} = \phi(z^{(l)})

where ϕ\phi is the activation function.

Activation Functions

Non-linear activation functions prevent stacked layers from collapsing into a single linear model:

  • Sigmoid: σ(z)=1/(1+ez)\sigma(z) = 1 / (1 + e^{-z}), squashing outputs to (0,1)(0, 1).
  • Tanh: tanh(z)=(ezez)/(ez+ez)\tanh(z) = (e^z - e^{-z}) / (e^z + e^{-z}), squashing to (1,1)(-1, 1).
  • ReLU: ReLU(z)=max(0,z)\text{ReLU}(z) = \max(0, z), preventing vanishing gradients.
  • ELU: ELU(z)=max(α(ez1),z)\text{ELU}(z) = \max(\alpha(e^z - 1), z), preventing dying neurons with small negative values.

Backpropagation

Backpropagation trains networks by computing the gradient of the loss function with respect to the weights using the chain rule of calculus, working backward from the output layer:

LW(l)=Lz(l)(a(l1))T\frac{\partial L}{\partial W^{(l)}} = \frac{\partial L}{\partial z^{(l)}} (a^{(l-1)})^T

The error term δ(l)=Lz(l)\delta^{(l)} = \frac{\partial L}{\partial z^{(l)}} is computed recursively from the output error using matrix multiplications.

Example: Forward Pass Calculations

The following example demonstrates calculating the forward pass of a single neuron using NumPy:

python

Interactive Lab

Compute the forward pass of a single neuron using weights, biases, and a ReLU activation function. Modify the input values to see if the neuron activates.

Step 1
Inspect the idea
Step 2
Edit the program
Step 3
Run and compare

Exercise

Test your understanding of activation functions:

Why did the deep learning community transition from Sigmoid activations to ReLU activations in hidden layers?

References & Further Reading

Previous Module Numerical Optimization