PatchMixer

Description

  • This API calls the PatchMixer model, which can be used for time series forecasting.

PatchMixer Model Architecture

Image Source: PatchMixer: A Patch-Mixing Architecture for Long-Term Time Series Forecasting Zeying Gong et al

PatchMixer is a model that splits a sequence into smaller temporal "patches" (sub-sequences) and mixes the information between these patches, then combines it back into the original time series data.

Key Features of PatchMixer:

  • Patch-based Time Series Representation
    • The time series data is divided into smaller segments (or patches), which are treated as separate units. These patches are designed to capture temporal patterns over a specific time window.
  • Temporal Dependency Modeling
    • By using mixing operations (usually fully connected or attention mechanisms), PatchMixer captures the dependencies between different patches of time, helping to model long-range dependencies and complex temporal patterns in the data.
  • Transformer-based Mechanism
    • Just like with images, PatchMixer leverages a transformer-like architecture to process these temporal patches, capturing both local and global patterns in the data.
  • Patch-wise Mixing
    • PatchMixer uses mixing layers (e.g., MLP layers or self-attention) to combine information across patches, allowing the model to learn relationships between different time segments.
  • Flexibility
    • It can be adapted for a variety of time series tasks like forecasting, anomaly detection, and classification by adjusting how the patches are constructed and how the model is trained.

API module path

from api.v2.model.PatchMixer import PatchMixer

Parameters

enc_in

  • Specifies the input feature size.
  • Example
    • If data's shape (x,x,1).
    • enc_in = 1

seq_len

  • Specifies the length of the input sequence.
  • Example
    • If data's shape (x,2,x).
    • seq_len = 2

pred_len

  • Specifies the prediction length.
  • Example
    • pred_len = 1

patch_len

  • Specifies the length of the sub-sequence.
  • This value cannot exceed the seq_len.
  • Example
    • patch_len = 1

stride

  • Specifies the interval between patches.
  • Example
    • stride = 1

mixer_kernel_size

  • Specifies the kernel size of the PatchMixer layer.
  • Example
    • mixer_kernel_size = 3

d_model

  • Specifies the hidden dim size.
  • This value sets the number of nodes in the intermediate layer.
  • Example
    • This value is typically set as a power of 2.
    • d_model = 128

dropout

  • Specifies the dropout rate of layers.
  • Example
    • dropout = 0.1

head_dropout

  • Specifies the dropout rate of multi-head attention.
  • Example
    • head_dropout = 0.1

e_layers

  • Specifies the number of layers in the model.
  • Example
    • e_layers = 2

Example Sample Code (Python)

Results

Check the entire module code.

datahub/api/v2/model/PatchMixer.py at main · machbase/datahub
All Industrial IoT DataHub with data visualization and AI source - machbase/datahub

Back to Top