Deep learning is the branch of machine learning that has driven most recent advances in vision, speech and language.

The Artificial Neuron

An artificial neuron (McCulloch and Pitts, 1943; Rosenblatt's perceptron, 1958) computes a weighted sum of its inputs plus a bias, z = w₁x₁ + w₂x₂ + ... + b, and passes it through an activation function to give the output. Common activations: step (0 or 1), sigmoid 1/(1 + e⁻ᶻ), tanh, ReLU max(0, z) and softmax for multi-class output. A single neuron can learn only linearly separable functions: it can represent AND and OR but not XOR.

Definition: Deep neural network. An artificial neural network with many hidden layers of neurons, trained on data by adjusting weights with backpropagation and gradient descent so that it learns hierarchical features.

Layers and Training

A neural network arranges neurons in layers: an input layer, one or more hidden layers and an output layer. A network with many hidden layers is deep. Hidden layers can solve XOR and any other function (the universal approximation theorem). Training adjusts the weights to minimise a loss function (such as cross-entropy or mean squared error): the forward pass computes the prediction; backpropagation computes the gradient of the loss with respect to each weight by the chain rule; gradient descent updates the weights, w ← w − η·∂L/∂w, where η is the learning rate. Data are fed in small batches, and a pass through all data is an epoch. Techniques against overfitting: dropout, regularisation, early stopping, data augmentation.

Main Architectures

Convolutional neural networks (CNNs) use filters sliding over images and are the standard for image tasks. Recurrent neural networks (RNNs) and LSTMs process sequences such as speech and text. Transformers, built on attention, power modern language models (GPT-style models, BERT) and increasingly vision. Autoencoders compress data; generative adversarial networks (GANs) and diffusion models generate images; large language models generate text. Deep learning needs large data, GPUs and much computing, and its decisions are hard to interpret.

Applications

Image classification and medical imaging, speech recognition and assistants, machine translation, chatbots, recommendation, self-driving perception, protein structure prediction (AlphaFold), fraud detection and content generation.

Table 4.2: Neural network architectures

Architecture Suited to Example
Feed-forward (MLP) Tabular data Credit scoring
CNN Images Face and object recognition
RNN / LSTM Sequences Speech, time series
Transformer Text and more Translation, chatbots
GAN / diffusion Generating data Image synthesis

Example 4.2: A network that computes XOR

Problem: Use step neurons to compute XOR of x₁, x₂ with a hidden layer: h₁ = step(x₁ + x₂ − 0.5) (OR), h₂ = step(x₁ + x₂ − 1.5) (AND), output = step(h₁ − h₂ − 0.5).

Solution:

  1. (0, 0): h₁ = 0, h₂ = 0, output step(−0.5) = 0.
  2. (0, 1): h₁ = 1, h₂ = 0, output step(0.5) = 1. (1, 0) gives the same: 1.
  3. (1, 1): h₁ = 1, h₂ = 1, output step(−0.5) = 0.

Result: The outputs 0, 1, 1, 0 match XOR, which a single neuron cannot compute.

step = lambda z: 1 if z > 0 else 0
def xor(x1, x2):
    h1 = step(x1 + x2 - 0.5)
    h2 = step(x1 + x2 - 1.5)
    return step(h1 - h2 - 0.5)
for a in (0, 1):
    for b in (0, 1):
        print(a, b, "->", xor(a, b))
w, eta = 0.0, 0.1
for _ in range(3):
    grad = 2 * (w * 2 - 4) * 2
    w -= eta * grad
    print("w =", round(w, 3))

Output

0 0 -> 0
0 1 -> 1
1 0 -> 1
1 1 -> 0
w = 1.6
w = 1.92
w = 1.984

Common mistakes

  • Believing a single neuron can learn XOR.
  • Choosing too high a learning rate, so the loss diverges.
  • Training for too long without a validation set, so the network overfits.
  • Treating a deep network's output as explained; it is largely a black box.

Key takeaways

  • Neuron: weighted sum + bias, then an activation (sigmoid, tanh, ReLU, softmax).
  • Training: forward pass, loss, backpropagation, gradient descent.
  • CNNs for images, RNNs/LSTMs for sequences, Transformers for language.
  • Deep learning needs large data and computing power.

Practice questions

  1. What does backpropagation compute?
  2. Which network type is used for images?
  3. Why can a single neuron not compute XOR?

Answers to the practice questions

  1. The gradient of the loss with respect to each weight, using the chain rule.
  2. Convolutional neural networks (CNNs).
  3. XOR is not linearly separable; a hidden layer is needed.

Sources

  • Official BCA syllabus Artificial Intelligence, course code 26BCA404DS04, Unit IV