An encoder is the sequence-processing component of a transformer. It receives embedded, position-aware time-series tokens and transforms them into contextual representations for the decoder. section 1.2
Each encoder combines self-attention with a feed-forward layer, and transformers usually stack many such layers. Unmasked self-attention relates each token to the known historical sequence, while multiheaded attention lets different heads learn patterns such as trends or seasonality. section 1.2.2
In time-series forecasting, the encoder:
- Learns importance weights and dependencies among historical tokens. section 1.2.2
- Builds increasingly deep representations as embeddings pass through stacked encoding layers. section 1.2.2
- Passes its output to the decoder, which uses that representation to generate predictions. section 1.2.3
Pattern-focused attention
Different attention heads can specialize in different properties of a time series: one may identify trends while another identifies seasonal patterns. A visualization may also show stronger attention to nearby time steps than distant history. section 1.2.2
Figure 1.5 The encoder is made of many encoders that have the same architecture. An encoder is made of a self-attention mechanism and a feed-forward layer.
Use the encoder diagram to see the repeated self-attention and feed-forward structure across stacked encoding layers. section 1.2.2




















