Abstract
We propose TimeHUT, a novel method for learning time-series representations by hierarchical uniformity-tolerance balancing of contrastive representations. Our method uses two distinct losses to learn strong representations with the aim of striking an effective balance between uniformity and tolerance in the embedding space. First, TimeHUT uses a hierarchical setup to learn both instance-wise and temporal information from input time-series. Next, we integrate a temperature scheduler within the vanilla contrastive loss to balance the uniformity and tolerance characteristics of the embeddings. Additionally, a hierarchical angular margin loss enforces instance-wise and temporal contrast losses, creating geometric margins between positive and negative pairs of temporal sequences. This approach improves the coherence of positive pairs and their separation from the negatives, enhancing the capture of temporal dependencies within a time-series sample. We evaluate our approach on a wide range of tasks, namely 128 UCR and 30 UAE datasets for univariate and multivariate classification, as well as Yahoo and KPI datasets for anomaly detection. The results demonstrate that TimeHUT outperforms prior methods by considerable margins on classification, while obtaining competitive results for anomaly detection.
Introduction
In self-supervised contrastive learning, models learn by pulling "positive" pairs (different views of the same data) together and pushing "negative" pairs (different data samples) apart. This process relies on two competing properties:
- Uniformity: Spreading representations evenly across the latent space to preserve as much information as possible.
- Tolerance: Allowing for small variations (noise, augmentations) so that semantically similar samples cluster together.
The "Goldilocks zone" between these two is difficult to maintain. If a model focuses too much on uniformity, it produces a scattered latent space with no clear clusters; if it focuses too much on tolerance, clusters overlap, losing the ability to distinguish between different classes. TimeHUT addresses this by dynamically balancing these properties through hierarchical learning and novel scheduling mechanisms.
Methodology
TimeHUT (Hierarchical Uniformity-Tolerance latent balancing) introduces three key innovations to solve the uniformity-tolerance trade-off, building upon the foundations of hierarchical architectures like TS2Vec.
Hierarchical Contrastive Learning
The framework captures features at multiple scales. It learns instance-level representations for global context and temporal-level representations for local, fine-grained patterns. This dual-focus ensures that the model understands both the overall shape of a time-series and its specific constituent segments.
Periodic Temperature Scheduling
Instead of a fixed temperature parameter, TimeHUT uses a sinusoidal ($\cos^2$) scheduler. By cycling the temperature, the model alternates between prioritizing uniformity (low temperature, sharp gradients) and tolerance (high temperature, smoother gradients). This "pulsing" allows the model to explore the representation space more effectively during training and avoid suboptimal local minima.
Hierarchical Angular Margin Loss
Borrowing techniques from face recognition, TimeHUT implements an angular margin loss. By treating the latent space as a hypersphere where the angle between vectors represents similarity, it enforces a minimum geometric gap between positive and negative pairs. This constraint prevents "semantic collapse" and ensures that even subtle temporal dependencies are captured by keeping distinct segments clearly separated.
Experiments and Results
Datasets
The authors conducted a massive evaluation across several benchmarks:
- Classification: 128 univariate datasets from the UCR archive and 30 multivariate datasets from the UEA archive.
- Anomaly Detection: The Yahoo and KPI datasets, containing real-world web traffic and system metrics.
- Forecasting: The ETTh1 and ETTh2 datasets (Electricity Transformer Temperature).
Key Results
TimeHUT sets a new bar for self-supervised time-series learning:
- Classification: On the 128 UCR datasets, it achieved an average accuracy of 86.4%, outperforming the previous state-of-the-art (SoftCLT at 85.0% and TS2Vec at 83.0%). It also achieved the best average rank (2.02) among all compared models.
- Anomaly Detection: It reached a state-of-the-art F1 score of 0.755 on the Yahoo dataset and 0.779 in "cold-start" scenarios.
- Efficiency: Despite the added complexity of the scheduler and margin, the training time overhead was minimal—only a ~2% increase compared to simpler baselines.
Discussion and Conclusion
The success of TimeHUT stems from the synergy between its components. Ablation studies show that while the temperature scheduler and angular margin help individually, their combination provides a significant jump in accuracy. By treating the latent space geometrically and pulsing the learning focus, TimeHUT effectively navigates the uniformity-tolerance trade-off.
However, limitations remain. The hierarchical approach struggles with very short sequences ($T < 20$) due to insufficient context, and the quadratic complexity of contrastive loss can be a bottleneck for extremely long sequences ($T > 10,000$). Future work may involve adapting these balancing mechanisms for non-stationary time-series or integrating them into transformer-based backbones.
Summary updated