Skip to content

📈 MultiScaleTrendMixing

📈 MultiScaleTrendMixing

🟡 Intermediate ✅ Stable ⏱️ Time Series

🎯 Overview

The MultiScaleTrendMixing layer mixes trend patterns across multiple time scales in a top-down (fine-to-coarse) fashion. It:

  1. Upsamples trend patterns from coarser scales
  2. Applies Dense Transformations at each scale
  3. Combines information from multiple scales
  4. Produces Multi-Scale Representations of trends

Complements MultiScaleSeasonMixing for complete TimeMixer encoding.

🔍 How It Works

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Input Coarse Trend
         |
         V
    [Apply Dense]
         |
         V
Output Coarse Scale
         |
         V
    [Upsample x2]
         |
         V
    [Apply Dense]
         |
         V
Output Medium Scale
         |
         V
      ...

💡 Why Use This Layer?

Multi-scale trend analysis captures: - Long-term patterns at coarse scales - Short-term variations at fine scales - Hierarchical structure of trends

📊 Use Cases

  • Multi-Horizon Forecasting: Different trend scales
  • Anomaly Detection: Trend changes at multiple scales
  • TimeMixer Encoder: Core component for trend decomposition

🚀 Quick Start

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import keras
from kerasfactory.layers import MultiScaleTrendMixing

trend_mix = MultiScaleTrendMixing(
    seq_len=96,
    down_sampling_window=2,
    down_sampling_layers=2
)

x_list = [keras.random.normal((32, 96, 64))]
output = trend_mix(x_list)
print(len(output))

🔧 API Reference

1
2
3
4
5
6
7
kerasfactory.layers.MultiScaleTrendMixing(
    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 Sampling factor
down_sampling_layers int 1 Number of layers
name str \| None None Optional layer name

Last Updated: 2025-11-04 | Keras: 3.0+ | Status: ✅ Production Ready