🌊 MultiScaleSeasonMixing
🌊 MultiScaleSeasonMixing
🟡 Intermediate
✅ Stable
⏱️ Time Series
🎯 Overview
The MultiScaleSeasonMixing layer mixes seasonal patterns across multiple time scales in a bottom-up (coarse-to-fine) fashion. It:
Downsamples seasonal patterns to coarser scales
Applies Dense Transformations at each scale
Combines information from multiple scales
Produces Multi-Scale Representations of seasonality
Used as part of TimeMixer's encoder to capture seasonality at different resolutions.
🔍 How It Works
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 Input Seasonal Patterns (Fine Scale)
|
V
+-------------------+
| Apply Dense |
| Transformations |
+--------+---------+
|
V
Output Scale 1 (Fine)
|
V
+-------------------+
| Downsample x2 |
+--------+---------+
|
V
+-------------------+
| Apply Dense |
| Transformations |
+--------+---------+
|
V
Output Scale 2 (Coarser)
|
V
...
💡 Why Use This Layer?
Challenge
Solution
Single Scale
✅ Multi-scale analysis
Loss of Detail
✅ Bottom-up blending
Seasonal Complexity
✅ Hierarchical patterns
📊 Use Cases
Multi-Seasonal Data : Multiple overlapping seasonal patterns
Hierarchical Forecasting : Predictions at different granularities
Pattern Discovery : Seasonal patterns at various scales
TimeMixer Encoder : Core component of forecasting model
🚀 Quick Start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import keras
from kerasfactory.layers import MultiScaleSeasonMixing
# Create seasonal mixing layer
season_mix = MultiScaleSeasonMixing (
seq_len = 96 ,
down_sampling_window = 2 ,
down_sampling_layers = 2
)
# Input: list of seasonal patterns at different scales
x_list = [ keras . random . normal (( 32 , 96 , 64 ))]
# Mix across scales
output = season_mix ( x_list )
print ( len ( output )) # Number of output scales
🔧 API Reference
kerasfactory . layers . MultiScaleSeasonMixing (
seq_len : int ,
down_sampling_window : int = 2 ,
down_sampling_layers : int = 1 ,
name : str | None = None ,
** kwargs : Any
)
Parameters
Parameter
Type
Default
Description
seq_len
int
—
Sequence length
down_sampling_window
int
2
Downsampling factor
down_sampling_layers
int
1
Number of downsampling layers
name
str \| None
None
Optional layer name
List of tensors, each shape (batch, channels, seq_len)
Output
List of mixed seasonal patterns at multiple scales
💡 Best Practices
Down-sampling Factor : 2-4 typical values
Number of Layers : 1-3 for most cases
Sequence Length : Must be divisible by downsampling factors
Input Order : Pass finest to coarsest scales
⚠️ Common Pitfalls
❌ Non-divisible seq_len : Causes shape mismatches
❌ Too many layers : Loss of fine-scale information
❌ Wrong input format : List required, not concatenated
📚 References
Zhou, T., et al. (2023). "TimeMixer: Decomposing Time Series for Forecasting"
Last Updated : 2025-11-04 | Keras : 3.0+ | Status : ✅ Production Ready