Papers › TS2Vec: Towards Universal Representation of Time Series

TS2Vec: Towards Universal Representation of Time Series

19 Jun 2021arXiv:2106.10466archive 2025-07-28

Zhihan Yue, Yujing Wang, Juanyong Duan, Tianmeng Yang, Congrui Huang, Yunhai Tong, Bixiong Xu

This paper presents TS2Vec, a universal framework for learning representations of time series in an arbitrary semantic level. Unlike existing methods, TS2Vec performs contrastive learning in a hierarchical way over augmented context views, which enables a robust contextual representation for each timestamp. Furthermore, to obtain the representation of an arbitrary sub-sequence in the time series, we can apply a simple aggregation over the representations of corresponding timestamps. We conduct extensive experiments on time series classification tasks to evaluate the quality of time series representations. As a result, TS2Vec achieves significant improvement over existing SOTAs of unsupervised time series representation on 125 UCR datasets and 29 UEA datasets. The learned timestamp-level representations also achieve superior results in time series forecasting and anomaly detection tasks. A linear regression trained on top of the learned representations outperforms previous SOTAs of time series forecasting. Furthermore, we present a simple way to apply the learned representations for unsupervised anomaly detection, which establishes SOTA results in the literature. The source code is publicly available at https://github.com/yuezhihan/ts2vec.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2106.10466")

Code

Syntology Ran 11 of 23 code samples harvested from 2 repositories linked to this paper; 12 have no recorded run. Of those that ran: 2 ran · violated contract; 3 ran · our draft was wrong; 5 ran · fixture could not drive it; 1 ran with no contract checked.

By repository: official repository: 18 samples from 1 repository, 9 ran; community (archive-listed): 5 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

zhihanyue/ts2vec officialmentioned on GitHubpytorchMIT report
xingyu617/SimTS_Representation_Learning mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

23 samples harvested; 11 ran; 0 honoured the contract we drafted; 12 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · violated contract
3ran · our draft was wrong
5ran · fixture could not drive it
1ran
12unverified

Licence: 0 of the 23 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

fit_svm zhihanyue/ts2vec/tasks/_eval_protocols.py official repository ran MIT (permissive) · c62d56549152cab0 · report
generate_binomial_mask zhihanyue/ts2vec/models/encoder.py official repository ran · violated contract MIT (permissive) · fd10054ec4772b80 · report
generate_continuous_mask zhihanyue/ts2vec/models/encoder.py official repository ran · violated contract MIT (permissive) · acda587a1d1be3bf · report
hierarchical_contrastive_loss zhihanyue/ts2vec/models/losses.py official repository ran · fixture could not drive it MIT (permissive) · 50140c8208c033ca · report
instance_contrastive_loss zhihanyue/ts2vec/models/losses.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · c2f2651c9a2df200 · report
pad_nan_to_target zhihanyue/ts2vec/utils.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 5254eb44ce12370e · report
pkl_load zhihanyue/ts2vec/utils.py official repository ran · our draft was wrong MIT (permissive) · 645d1fdb1dc0e80c · report
temporal_contrastive_loss zhihanyue/ts2vec/models/losses.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 72ddf2810ea340c7 · report
torch_pad_nan zhihanyue/ts2vec/utils.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 79783deb10f33397 · report
eval_ad_result zhihanyue/ts2vec/tasks/anomaly_detection.py official repository unverified MIT (permissive) · 47121228bf8548c3 · report
eval_classification zhihanyue/ts2vec/tasks/classification.py official repository unverified MIT (permissive) · 9fefe06e6c5ec2ba · report
fit_knn zhihanyue/ts2vec/tasks/_eval_protocols.py official repository unverified MIT (permissive) · befe203f4fa96ee5 · report
fit_lr zhihanyue/ts2vec/tasks/_eval_protocols.py official repository unverified MIT (permissive) · 2309c20a08ac1773 · report
get_range_proba zhihanyue/ts2vec/tasks/anomaly_detection.py official repository unverified MIT (permissive) · 9e3f8a516d6d6bda · report
load_UCR zhihanyue/ts2vec/datautils.py official repository unverified MIT (permissive) · 589ba3938a15e163 · report
load_UEA zhihanyue/ts2vec/datautils.py official repository unverified MIT (permissive) · 017c065ca560f687 · report
load_forecast_npy zhihanyue/ts2vec/datautils.py official repository unverified MIT (permissive) · ee0abcf391ea662f · report
reconstruct_label zhihanyue/ts2vec/tasks/anomaly_detection.py official repository unverified MIT (permissive) · a537f33988462d8c · report
cal_metrics xingyu617/SimTS_Representation_Learning/tasks/forecasting.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · a4750195b8805692 · report
segment xingyu617/SimTS_Representation_Learning/simts.py community (archive-listed) ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · c11f79ab12e7b749 · report
eval_classification xingyu617/SimTS_Representation_Learning/tasks/classification.py community (archive-listed) unverified Apache-2.0 (permissive) · ab1fea29d1c61d99 · report
eval_forecasting xingyu617/SimTS_Representation_Learning/tasks/forecasting.py community (archive-listed) unverified Apache-2.0 (permissive) · 119ba424fe985113 · report
generate_pred_samples xingyu617/SimTS_Representation_Learning/tasks/forecasting.py community (archive-listed) unverified Apache-2.0 (permissive) · 63e193a1a856ae88 · report

Tasks

Anomaly DetectionContrastive LearningTime SeriesTime Series AnalysisTime Series ClassificationTime Series ForecastingUnsupervised Anomaly Detection

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Contrastive LearningLinear RegressionMax Pooling

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections