Advanced Layers: Normalization, Attention, and Sequence Models
From MLPs to Structured Deep Networks
Layer design
Advanced models combine affine maps, nonlinearities, normalization, residual paths, and structured mixing mechanisms. The key insight is that depth alone is rarely sufficient; architectural inductive bias strongly shapes performance. In sequence tasks, recurrent, convolutional, and attention-based layers each encode different assumptions about locality, order, and long-range dependence.
Major sequence modeling paradigms
RNN/LSTM/GRU
- Strong inductive bias for temporal order
- Can struggle with very long dependencies
CNN-based sequence models
- Local receptive fields and parallelism
- Need depth to capture global context
Normalization
Batch normalization, layer normalization, and related methods stabilize optimization by controlling activation statistics. The specific choice depends on batch size, architecture, and training regime. For example, layer normalization is often preferred in transformer-style architectures where batch statistics may be less informative.
Why is layer normalization often useful in transformer models?
Layer normalization is suited to sequence models and does not depend on batch-wide statistics in the same way as batch normalization.
Correct answer: It normalizes across features and works well with variable batch statistics
What problem do residual connections help address?
Skip connections facilitate gradient flow and support very deep architectures.
Correct answer: Vanishing gradients and optimization difficulty in deep networks
Attention Mechanisms
Scaled dot-product attention
Attention computes data-dependent weighting over value vectors using query and key similarity. A common form is . Multi-head attention extends this by learning multiple subspaces, improving expressivity and enabling different relational patterns to be modeled simultaneously.
Research insight
Attention is not a single mechanism but a family of weighted retrieval operators; its behavior depends heavily on positional encoding and masking.
What does the term in scaled dot-product attention help with?
Scaling prevents dot products from growing too large as dimensionality increases, which helps softmax remain well-behaved.
Correct answer: It stabilizes the magnitude of dot products before softmax
Name one role of positional encoding in attention models.
Without positional information, attention alone cannot infer sequence order.
Correct answer: It injects order information into a permutation-invariant attention mechanism.