Dilated Convolutional Models#

Models that use dilated 1D convolutions for multi-scale time-series representations. All three share PoolingEncodingMixin for sliding-window, multi-resolution encoding.

TS2Vec#

Hierarchical contrastive learning via progressively dilated convolutions.

class chronocratic.models.convolutional.dilated.ts2vec.model.TS2Vec(*, input_dims: int, augmentation: AugmentationProducer[AlignedPair] | None = None, hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, conv_kernel_size: int = 3, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, max_train_length: int | None = None, temporal_unit: int = 0, sync_dist: bool = False)#

Bases: LightningModule, PoolingEncodingMixin

TS2Vec Model.

Code source: zhihanyue/ts2vec

property encoder: TS2VecTimeSeriesEncoder#

Return the primary (non-averaged) encoder for inspection and checkpointing.

configure_optimizers() AdamW#

Return the AdamW optimizer for the TS2Vec encoder.

training_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor#

Run one TS2Vec training step with manual optimization.

validation_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor#

Compute and log the TS2Vec validation loss.

Configuration for the TS2Vec model.

Provides TS2VecModelParameters with all TS2Vec-specific runtime settings: mask mode, learning rate, training length cap, temporal unit, and distributed-sync flag.

class chronocratic.models.convolutional.dilated.ts2vec.config.TS2VecModelParameters(*, input_dims: int, hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, conv_kernel_size: int = 3, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, max_train_length: int | None = None, temporal_unit: int = 0, sync_dist: bool = False)#

Bases: object

Configuration for the TS2Vec model.

Parameters:
  • input_dims – Number of input features (channels) in the time series.

  • hidden_dims – Number of hidden units in each encoder layer.

  • output_dims – Number of output features produced by the encoder.

  • depth – Number of encoder layers.

  • dropout_rate – Dropout probability applied after each encoder layer.

  • conv_kernel_size – Size of the convolutional kernel in each layer.

  • mask_mode – Strategy for masking input tokens during training.

  • learning_rate – Base learning rate for the optimizer.

  • max_train_length – Maximum sequence length; longer samples are truncated. None means no limit.

  • temporal_unit – Token-level temporal unit index.

  • sync_dist – Whether to synchronize metrics across distributed processes.

CoST#

Contrastive Seasonality-Trend decomposition for time-series pretraining.

class chronocratic.models.convolutional.dilated.cost.model.CoST(*, input_dims: int, sequence_length: int, kernel_sizes: tuple[int, ...] = (1, 2, 4, 8, 16, 32, 64, 128), augmentation: AugmentationProducer[ViewPair] | None = None, max_train_length: int = 201, hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, seasonal_loss_weight: float = 0.1, queue_size: int = 65536, momentum: float = 0.999, temperature: float = 0.07, sync_dist: bool = False)#

Bases: LightningModule, DecompositionEncodingMixin

CoST Model.

Code source: salesforce/CoST

on_fit_start() None#

Initialize the numpy RNG after the trainer has set the PyTorch seed.

property encoder: Module#

Return the query encoder for inspection and checkpointing.

configure_optimizers() SGD#

Return SGD optimizer over trainable query encoder and projection head parameters.

training_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor#

Augment the batch twice, compute the contrastive loss, perform a manual update step.

validation_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor#

Compute and log the contrastive validation loss without updating model parameters.

Configuration for the CoST model.

Provides CoSTModelParameters with CoST-specific settings including seasonal-trend decomposition encoder parameters and contrastive learning configuration.

class chronocratic.models.convolutional.dilated.cost.config.CoSTModelParameters(*, input_dims: int, sequence_length: int, kernel_sizes: tuple[int, ...] = (1, 2, 4, 8, 16, 32, 64, 128), max_train_length: int = 201, hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, seasonal_loss_weight: float = 0.1, queue_size: int = 65536, momentum: float = 0.999, temperature: float = 0.07, sync_dist: bool = False)#

Bases: object

Configuration for the CoST model.

Parameters:
  • input_dims – Number of input features (channels) in the time series.

  • sequence_length – Length of each input time series sample.

  • kernel_sizes – DWT decomposition levels as kernel sizes.

  • max_train_length – Maximum sequence length for training samples.

  • hidden_dims – Number of hidden units in each encoder layer.

  • output_dims – Number of output features produced by the encoder.

  • depth – Number of encoder layers.

  • dropout_rate – Dropout probability applied after each encoder layer.

  • mask_mode – Strategy for masking input tokens during training.

  • learning_rate – Base learning rate for the optimizer.

  • seasonal_loss_weight – Weight for the seasonal contrastive loss term.

  • queue_size – Size of the memory queue for contrastive learning.

  • momentum – Momentum coefficient for the key encoder update.

  • temperature – Temperature scaling for the contrastive loss.

  • sync_dist – Whether to synchronize metrics across distributed processes.

AutoTCL#

Adversarial unsupervised contrastive learning with trainable augmentation.

class chronocratic.models.convolutional.dilated.autotcl.model.AutoTCL(*, input_dims: int, kernel_sizes: tuple[int, ...] = (3, 5, 7), augmentation: AugmentationProducer[SingleView] | None = None, hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, conv_kernel_size: int = 3, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, max_train_length: int | None = None, meta_learning_rate: float = 0.01, local_loss_weight: float = 0.1, sync_dist: bool = False)#

Bases: LightningModule, PoolingEncodingMixin

AutoTCL Model.

Code source: AslanDing/AutoTCL

property encoder: AutoTCLTimeSeriesEncoder#

Return the primary (non-averaged) encoder for inspection and checkpointing.

configure_optimizers() AdamW | list[AdamW]#

Return encoder optimizer(s); two optimizers when using trainable aug.

training_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor | None#

Run one AutoTCL training step with manual optimization.

Two-phase training: 1. Aug network self-training (via centralized maybe_train_augmentation gate). 2. Uniform encoder training (all augmentation types).

validation_step(batch: Tensor | tuple[Tensor, ...], batch_idx: int) Tensor#

Compute validation contrastive loss using the averaged encoder.

Configuration for the AutoTCL model.

Provides AutoTCLModelParameters with AutoTCL-specific settings: DWT kernel sizes for multi-scale feature extraction, mask mode, learning rate, training length cap, and distributed-sync flag.

class chronocratic.models.convolutional.dilated.autotcl.config.AutoTCLModelParameters(*, input_dims: int, kernel_sizes: tuple[int, ...] = (3, 5, 7), hidden_dims: int = 64, output_dims: int = 320, depth: int = 10, dropout_rate: float = 0.1, conv_kernel_size: int = 3, mask_mode: MaskMode = MaskMode.BINOMIAL, learning_rate: float = 0.001, max_train_length: int | None = None, meta_learning_rate: float = 0.01, local_loss_weight: float = 0.1, sync_dist: bool = False)#

Bases: object

Configuration for the AutoTCL model.

Parameters:
  • input_dims – Number of input features (channels) in the time series.

  • kernel_sizes – DWT decomposition levels as kernel sizes.

  • hidden_dims – Number of hidden units in each encoder layer.

  • output_dims – Number of output features produced by the encoder.

  • depth – Number of encoder layers.

  • dropout_rate – Dropout probability applied after each encoder layer.

  • conv_kernel_size – Size of the convolutional kernel in each layer.

  • mask_mode – Strategy for masking input tokens during training.

  • learning_rate – Base learning rate for the optimizer.

  • max_train_length – Maximum sequence length; longer samples are truncated. None means no limit.

  • meta_learning_rate – Learning rate for the augmentation network optimizer.

  • local_loss_weight – Weight for the local InfoNCE loss term in the encoder contrastive loss.

  • sync_dist – Whether to synchronize metrics across distributed processes.