Skip to content
New
Latest News || 27 October 2026: Dr Soumava Mukherjee's invited talk at Queen's University Belfast joined device-level hardware innovation with channel-level control. || 22 October 2026: I received a Certificate of Appreciation for serving as a reviewer for IEEE IMAS 2026. || 15 October 2026: I presented a poster on beam-domain ML fingerprinting for RIS-aided mmWave localisation at the Centre for Wireless Innovation's annual symposium. || 15 October 2026: CWI's annual symposium brought research and industry perspectives on 6G, ISAC, optical wireless, AI, and future networks to Queen's University Belfast. || 14 October 2026: Erik Nordell of Ericsson visited our Keysight Lab for a live RIS-assisted video streaming demonstration.
Knowledge Hubmachine learning9. Deep Learning Architectures

machine learning learning note

9. Deep Learning Architectures

A clearer and deeper guide to neural networks, CNNs, RNNs, transformers, training, and practical limitations.

At a glance

  • Compose weighted sums and nonlinearitiesA neuron applies an activation to a weighted sum; successive nonlinear layers can learn richer functions.
  • Follow both values and derivativesA forward pass computes an output. Backpropagation propagates loss gradients through those same operations.
  • Architecture is an assumptionCNNs exploit local grids, recurrent models carry state, and attention compares tokens. Validate the architecture on the actual task.

What is Deep Learning?

Deep learning uses neural networks with multiple learned layers.

  • Early layers: can detect simpler patterns.
  • Later layers: combine them into task-relevant representations.
  • Physical caution: what a layer learns depends on data and training; it is not guaranteed to match a human concept.

For images, early layers may detect edges. Middle layers may detect shapes and textures. Deeper layers may detect objects. For language, early layers may learn local word patterns, while deeper layers learn meaning and context.

LeCun, Bengio, and Hinton described deep learning as using multiple processing layers to learn data representations with multiple levels of abstraction.

References for this section3

Why Deep Learning Became Powerful

Deep learning became dominant because three things arrived together:

  • Large datasets: Images, text, speech, sensor data, and web-scale corpora.
  • Computation: GPUs and distributed training made large neural networks practical.
  • Algorithmic improvements: Better activation functions, initialization, normalization, optimization, and architectures.

Traditional ML often requires manual feature engineering. Deep learning can learn features directly from raw or lightly processed data.

References for this section3

The Neuron

A neuron receives inputs, multiplies them by weights, adds a bias, and passes the result through an activation function.

a=g ⁣(β0+∑j=1pβjxj)a=g\!\left(\beta_0+\sum_{j=1}^{p}\beta_jx_j\right)
  • xjx_{j}: input feature j.
  • βj\beta _{j}: learned weight for feature j.
  • β0\beta _{0} is the bias.
  • gg converts the weighted sum to output a
  • pp is the number of inputs.

The activation function introduces non-linearity. Without non-linearity, stacking layers would still behave like one linear model.

Common activation functions:

  • Sigmoid: Maps values to 0-1, but can suffer from vanishing gradients.
  • Tanh: Maps values to -1 to 1.
  • ReLU: Simple and widely used; outputs zero for negative inputs.
  • GELU: Common in transformer models.

Where does a neural-network output and its gradient come from?

1. Formula and symbols
z1=x+y−0.2,z2=x−y+0.1z_1=x+y-0.2,\quad z_2=x-y+0.1
p=σ(g[a(z1)−a(z2)])p=\sigma(g[a(z_1)-a(z_2)])
∂p∂x=p(1−p)g[a′(z1)−a′(z2)]\frac{\partial p}{\partial x}=p(1-p)g[a'(z_1)-a'(z_2)]
  • xx: First input feature
  • yy: Second input feature
  • zz: hidden weighted sums
  • aa: selected activation
  • gg: output gain
  • σ\sigma: sigmoid
  • pp: output value

Constants are the fixed demonstration weights/biases

the derivative is local sensitivity.

x 0.10y 0.60h₁ 0.500h₂ 0.000p 0.731Fixed weights → activation → shared-gain output sigmoid+g−g
Hidden activation a
2. Work with the current inputs
z1=x+y−0.2=0.500,z2=x−y+0.1=−0.400z_1=x+y-0.2=0.500,\quad z_2=x-y+0.1=-0.400
p=σ(g[a(z1)−a(z2)])=σ(1.000)=0.731p=\sigma(g[a(z_1)-a(z_2)])=\sigma(1.000)=0.731
∂p∂x=p(1−p)g[a′(z1)−a′(z2)]=0.39322\frac{\partial p}{\partial x}=p(1-p)g[a'(z_1)-a'(z_2)]=0.39322
3. Result
Output sigmoid value0.731
Hidden outputs h₁ / h₂0.500 / 0.000
Local derivative ∂p/∂x0.39322
A hand-specified 2-input, 2-hidden-unit network, not a trained classifier. Hidden weights/biases are fixed; the output uses a shared positive/negative gain and a sigmoid. The input derivative follows the chain rule. ReLU derivative is defined as zero at exactly zero for this demo. Small derivatives illustrate local sensitivity, not an entire deep network’s training behavior.
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

1. Artificial Neural Networks

An Artificial Neural Network (ANN), also called a multilayer perceptron when fully connected, is the basic neural network architecture.

References for this section3

Best For

  • Tabular data.
  • Simple non-linear prediction.
  • Baseline deep learning experiments.
References for this section3

How It Works

Each neuron in one layer connects to neurons in the next layer. Information flows forward from input to output. During training, backpropagation computes gradients, and an optimizer updates the weights.

References for this section3

Strengths

  • Learns non-linear functions.
  • Flexible and general.
  • Easy to build compared with specialized networks.
References for this section3

Weaknesses

  • Does not naturally exploit image structure or sequence order.
  • Can overfit small datasets.
  • Requires scaling and careful training.
References for this section3

2. Deep Neural Networks

A Deep Neural Network (DNN) is an ANN with many hidden layers. Depth allows the model to learn hierarchical representations.

References for this section3

Intuition

One layer learns simple combinations. Several layers can build more complex functions by composing simple ones.

Example for image recognition:

pixels -> edges -> corners -> parts -> object
References for this section3

Training Challenges

Deep networks can be hard to train because gradients may vanish, explode, or become noisy. Modern networks use tools such as:

  • Careful initialization.
  • ReLU or GELU activations.
  • Batch normalization or layer normalization.
  • Dropout.
  • Residual connections.
  • Adam or AdamW optimizers.

Why do deep networks need careful activations and initialisation?

1. Formula and symbols
hℓ=a(zℓ),zℓ=Wℓhℓ−1h_\ell=a(z_\ell),\qquad z_\ell=W_\ell h_{\ell-1}
δℓ=a′(zℓ)⊙(Wℓ+1⊤δℓ+1),∥δ1∥≈∥δL∥∏ℓ(s ∣a′∣‾)\delta_\ell=a'(z_\ell)\odot\big(W_{\ell+1}^\top\delta_{\ell+1}\big),\qquad\lVert\delta_1\rVert\approx\lVert\delta_L\rVert\prod_{\ell}\big(s\,\overline{|a'|}\big)
  • hℓh_\ell: Output of layer ℓ (8 neurons wide)
  • WℓW_\ell: Weight matrix of layer ℓ, drawn with standard deviation s/√8
  • a, a′a,\ a': Activation function and its derivative
  • δℓ\delta_\ell: Gradient signal that reaches layer ℓ during backpropagation
  • LL: Number of layers
  • ss: Weight-initialisation scale

Each layer multiplies the backward signal by roughly s·|a′|. Sigmoid has |a′| ≤ 0.25, so deep sigmoid stacks shrink the signal geometrically; a large s can make it grow instead.

inputoutput + lossforward pass →−10−50log₁₀ ‖gradient‖ reaching each layerlayer 1 (near input) → layer 8 (near output)
Activation
2. Work with the current inputs
∥δ1∥=8.33×10−7,∥δ8∥=2.43×10−1\lVert\delta_1\rVert=8.33\times10^{-7},\quad\lVert\delta_{8}\rVert=2.43\times10^{-1}
∥δ1∥∥δL∥=3.43×10−6(vanishing)\frac{\lVert\delta_1\rVert}{\lVert\delta_L\rVert}=3.43\times10^{-6}\quad(vanishing)
3. Result
Gradient at first layer8.3e-7
First / last layer ratio3.4e-6vanishing
A seeded 8-neuron-wide network: the teal pulse is the forward pass, the orange pulse is backpropagation. The bars show how strong the gradient is when it reaches each layer, on a log scale. With sigmoid the first layers receive almost nothing (vanishing gradient), so they barely learn. ReLU or tanh with a sensible scale keep the signal alive; a large scale makes it explode.
References for this section3

3. Convolutional Neural Networks

Convolutional Neural Networks (CNNs) are designed for grid-like data, especially images.

References for this section3

Why CNNs Work Well for Images

Images have local structure. Nearby pixels are related. A CNN uses small filters that slide across the image and detect local patterns such as edges, textures, and corners.

References for this section3

Main Components

  • Convolution: Applies filters to detect patterns.
  • Activation: Adds non-linearity.
  • Pooling: Reduces spatial size and improves robustness.
  • Fully connected layer: Uses learned features for final prediction.

A CNN filter sliding over an image

1. Formula and symbols
Y[i,j]=∑a=02∑b=02K[a,b]  X[iS−P+a, jS−P+b]Y[i,j]=\sum_{a=0}^{2}\sum_{b=0}^{2}K[a,b]\;X[iS-P+a,\ jS-P+b]
Nout=⌊N−k+2PS⌋+1,pool: Z[i,j]=max⁡2×2ReLU(Y)N_{\rm out}=\Big\lfloor\frac{N-k+2P}{S}\Big\rfloor+1,\qquad\text{pool: }Z[i,j]=\max_{2\times2}\mathrm{ReLU}(Y)
  • XX: Input image, N × N = 8 × 8 pixels (1 = bright, 0 = dark)
  • KK: 3 × 3 filter (kernel): 9 shared weights
  • YY: Feature map: how strongly the pattern appears at each position
  • kk: Kernel size (3)
  • SS: Stride: how many pixels the window jumps
  • PP: Zero padding added around the border
  • ZZ: Pooled map: the largest positive response in each 2 × 2 block

Deep-learning libraries call this operation convolution, although mathematically it is cross-correlation (the kernel is not flipped).

Input 8×8Filter 3×3−1−1−1000111Feature map 6×6ReLU + max-pool→image → convolution (find a pattern) → ReLU (keep positives) → pooling (shrink)Stacked blocks: early filters find edges, later ones combine them into strokes and digits.
Filter
Stride S
Padding P
2. Work with the current inputs
Nout=⌊8−3+2(0)1⌋+1=6,pooled: 3×3N_{\rm out}=\Big\lfloor\frac{8-3+2(0)}{1}\Big\rfloor+1=6,\qquad\text{pooled: }3\times3
Y[1,1]=0=0.00Y[1,1]=0=0.00
parameters: 3×3+1=10 (shared)vs dense 64×36=2304\text{parameters: }3\times3+1=10\ \text{(shared)}\quad\text{vs dense }64\times36=2304
3. Result
Feature-map size6 × 6after pooling: 3 × 3
Response at the window0.00dark→bright top to bottom
Weights in this layer10a dense layer would need 2304
An 8 × 8 picture of the digit 7. The orange window is where the 3 × 3 filter currently sits; its weighted sum becomes one cell of the feature map (ringed). The same nine weights are reused at every position, which is why a CNN needs far fewer parameters than a fully connected layer. Teal = strong positive response, purple = negative. ReLU then keeps the positives and 2 × 2 max-pooling shrinks the map.
References for this section3

Best For

  • Image classification.
  • Object detection.
  • Medical imaging.
  • Remote sensing.
  • Spectrogram and signal-pattern recognition.
References for this section3

4. Recurrent Neural Networks

Recurrent Neural Networks (RNNs) are designed for sequential data. They process one step at a time and maintain a hidden state that carries information from previous steps.

An RNN unrolled in time: how long does it remember?

1. Formula and symbols
ht=tanh⁡(w ht−1+u xt),h0=0h_t=\tanh(w\,h_{t-1}+u\,x_t),\qquad h_0=0
∂hT∂ht=∏k=t+1Tw (1−hk2)\frac{\partial h_T}{\partial h_t}=\prod_{k=t+1}^{T}w\,(1-h_k^2)
  • xtx_t: Input at step t (one event at t = 1, then zeros)
  • hth_t: Hidden state: the network’s memory after step t
  • ww: Recurrent weight: how much of the old memory is kept
  • uu: Input weight
  • TT: Sequence length
  • ∂hT/∂ht\partial h_T/\partial h_t: How much the last state still depends on step t; training signals travel back through this product

The same w and u are reused at every step. If |w(1 − h²)| < 1 the product shrinks geometrically: the plain RNN forgets, which LSTM and GRU gates were designed to fix.

h10.91x=1h20.62x=0h30.46x=0h40.35x=0h50.27x=0h60.22x=0h70.17x=0h80.14x=0h90.11x=0Same cell reused at every step · numbers above: hidden state h_t · orange: input event−4−20log₁₀ |∂h_T / ∂h_t|
2. Work with the current inputs
h1=tanh⁡(0.8×0.000+1.5×1)=0.905h_{1}=\tanh(0.8\times0.000+1.5\times1)=0.905
∂h9∂h1=∏k=290.8(1−hk2)=5.94×10−2\frac{\partial h_{9}}{\partial h_1}=\prod_{k=2}^{9}0.8(1-h_k^2)=5.94\times10^{-2}
3. Result
Memory left at step 90.108started at h₁ = 0.905
Dependence of h_T on h₁5.9e-2
Steps with dependence ≥ 0.18 of 9
One event arrives at step 1, then the inputs are zero. Each box is the same RNN cell applied again, passing its hidden state to the right (the moving highlight shows the current step). The top numbers show how much of the event is still in memory; the bars show how strongly the final state depends on each earlier step (log scale), which is also how strongly a training error can reach back to it.
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Best For

  • Time series.
  • Speech.
  • Sensor streams.
  • Sequential control signals.
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Limitations

Standard RNNs struggle with long-range dependencies. LSTM and GRU architectures were designed to remember information for longer periods, but transformers now dominate many sequence modeling tasks.

References for this section3

5. Transformers

Transformers are neural networks built around attention mechanisms. Instead of processing a sequence strictly step by step, attention allows the model to compare each token with other tokens directly.

References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Why Attention Matters

In a sentence, the meaning of one word may depend on another word far away. Attention helps the model decide which parts of the input are most relevant.

Self-attention: which words does each word look at?

1. Formula and symbols
sij=qi⊤kjdk,αij=esij∑j′esij′s_{ij}=\frac{q_i^\top k_j}{\sqrt{d_k}},\qquad\alpha_{ij}=\frac{e^{s_{ij}}}{\sum_{j'}e^{s_{ij'}}}
oi=∑jαijvj(causal mask: αij=0 for j>i)o_i=\sum_j\alpha_{ij}v_j\qquad\text{(causal mask: }\alpha_{ij}=0\text{ for }j>i)
  • qiq_i: Query of token i: what this token is looking for
  • kjk_j: Key of token j: what token j offers (here k_j = c·e_j)
  • vjv_j: Value of token j: the content passed on (here v_j = e_j)
  • dkd_k: Key dimension (4)
  • sijs_{ij}: Scaled similarity score
  • αij\alpha_{ij}: Attention weight: share of token i’s focus on token j (each row sums to 1)
  • oio_i: New representation of token i: a weighted mix of the values

The vectors are hand-set along four readable directions (device, person, action, grammar) to show the mechanism; a trained transformer learns them, uses hundreds of dimensions and many heads in parallel.

The4%beam5%missed5%the4%user40%because4%it27%moved12%Query “it” (orange) → attention weights (arc thickness)Attention matrix (row = query)Thebeammissedtheuserbecauseitmoved12345678Output o for “it”device0.15person0.68action0.18grammar0.22
Query word
Causal mask
2. Work with the current inputs
s7,j=q7⊤(3ej)4,α7,⋅=(0.04, 0.05, 0.05, 0.04, 0.40, 0.04, 0.27, 0.12)s_{7,j}=\frac{q_{7}^\top(3e_j)}{\sqrt4},\quad\alpha_{7,\cdot}=(0.04,\ 0.05,\ 0.05,\ 0.04,\ 0.40,\ 0.04,\ 0.27,\ 0.12)
o7=∑jα7jej=(0.15, 0.68, 0.18, 0.22)  [device, person, action, grammar]o_{7}=\sum_j\alpha_{7j}e_j=(0.15,\ 0.68,\ 0.18,\ 0.22)\ \ [\text{device, person, action, grammar}]
3. Result
“it” attends most to“user” (40%)then “it” 27%
Strongest meaning in outputperson
Pick a query word. Arcs show how its attention is shared among all words (thicker = more), and the matrix shows every word’s attention row at once. The word “it” should look mainly at “user”, because its query asks for a person. A larger key scale makes the softmax sharper; that is why real transformers divide the scores by √dₖ. The causal mask hides future words, as in GPT-style decoders.
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Best For

  • Language models.
  • Machine translation.
  • Text classification.
  • Vision transformers.
  • Multimodal models combining text, images, and audio.
References for this section3

Training a Deep Network

The training loop is usually:

  1. Send a batch of data through the network.
  2. Compute the loss.
  3. Use backpropagation to compute gradients.
  4. Update weights using an optimizer.
  5. Repeat over many batches and epochs.

Backpropagation became a key foundation for modern neural networks after the work of Rumelhart, Hinton, and Williams in 1986.

References for this section3

Regularization

Deep networks can memorize training data. Regularization helps them generalize.

Common techniques:

  • Dropout: Randomly disables neurons during training.
  • Weight decay: Penalizes overly large weights.
  • Data augmentation: Creates modified training examples.
  • Early stopping: Stops training when validation performance stops improving.
  • Batch/layer normalization: Stabilizes training.
References for this section3

When Deep Learning is a Good Choice

Deep learning is usually strong when:

  • The dataset is large.
  • The input is complex, such as image, audio, text, or raw signal data.
  • Manual feature engineering is difficult.
  • High predictive performance is more important than simple interpretability.

It may not be the best first choice when:

  • The dataset is small.
  • Interpretability is the main requirement.
  • The problem is simple tabular prediction.
  • Compute resources are limited.
References for this section3

Python: Load a DNN with Keras

Use a DNN when your features are tabular or already converted into numeric vectors. The Sequential API is the simplest way to stack layers.

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers

model = keras.Sequential([
    layers.Input(shape=(20,)),
    layers.Dense(64, activation="relu"),
    layers.Dropout(0.2),
    layers.Dense(32, activation="relu"),
    layers.Dense(1, activation="sigmoid"),
])

model.compile(
    optimizer="adam",
    loss="binary_crossentropy",
    metrics=["accuracy"]
)

# X_train shape: (samples, 20), y_train shape: (samples,)
# model.fit(X_train, y_train, validation_split=0.2, epochs=20, batch_size=32)
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Python: Load a CNN for Image Classification

CNNs expect image-like tensors. For RGB images of size 128 x 128, the input shape is (128, 128, 3).

from tensorflow import keras
from tensorflow.keras import layers

cnn = keras.Sequential([
    layers.Input(shape=(128, 128, 3)),
    layers.Rescaling(1.0 / 255),
    layers.Conv2D(32, 3, activation="relu"),
    layers.MaxPooling2D(),
    layers.Conv2D(64, 3, activation="relu"),
    layers.MaxPooling2D(),
    layers.Flatten(),
    layers.Dense(128, activation="relu"),
    layers.Dense(10, activation="softmax"),
])

cnn.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"]
)
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Python: Load an RNN/LSTM for Sequence Data

For sequence data, the input shape is usually (time_steps, features_per_step).

from tensorflow import keras
from tensorflow.keras import layers

lstm_model = keras.Sequential([
    layers.Input(shape=(50, 8)),
    layers.LSTM(64),
    layers.Dense(32, activation="relu"),
    layers.Dense(1),
])

lstm_model.compile(
    optimizer="adam",
    loss="mse",
    metrics=["mae"]
)
References for this section3
  • Keras documentation, "The Sequential model".
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.

Python: Save and Load a Deep Learning Model

model.save("dnn_model.keras")

loaded_model = keras.models.load_model("dnn_model.keras")
# predictions = loaded_model.predict(X_test)

For real projects, keep preprocessing with the model or document it carefully. A neural network trained on normalized data will perform badly if deployed on raw unnormalized data.

References for this section3
  • Y. LeCun, Y. Bengio, and G. Hinton, "Deep learning", Nature, vol. 521, pp. 436-444, 2015.
  • I. Goodfellow, Y. Bengio, and A. Courville, Deep Learning, MIT Press, 2016.
  • Keras documentation, "The Sequential model".

Takeaway

  • CNN: useful for spatial grids such as images.
  • RNN: models ordered sequences.
  • Transformer: uses attention to relate positions in a sequence.
  • Cost: data, compute, regularization, and careful held-out evaluation.

Continue with Reinforcement Learning and Deep RL to build on this note.

References for this section3

Check your understanding

0 of 4 answered

  1. What is ReLU(−2)?

  2. What happens when affine layers are stacked without any nonlinear activation?

  3. For h=ReLU(x+y−0.2), what is h at x=0.1, y=0.6?

  4. Which component directly compares representations across token positions?

Complete references and further reading