{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/cost-contrastive-learning-of-disentangled-1","title":"CoST: Contrastive Learning of Disentangled Seasonal-Trend Representations for Time Series Forecasting","arxiv_id":"2202.01575","date":"2022-02-03","proceeding":"ICLR 2022 4","authors":["Gerald Woo","Chenghao Liu","Doyen Sahoo","Akshat Kumar","Steven Hoi"],"abstract":"Deep learning has been actively studied for time series forecasting, and the mainstream paradigm is based on the end-to-end training of neural network architectures, ranging from classical LSTM/RNNs to more recent TCNs and Transformers. Motivated by the recent success of representation learning in computer vision and natural language processing, we argue that a more promising paradigm for time series forecasting, is to first learn disentangled feature representations, followed by a simple regression fine-tuning step -- we justify such a paradigm from a causal perspective. Following this principle, we propose a new time series representation learning framework for time series forecasting named CoST, which applies contrastive learning methods to learn disentangled seasonal-trend representations. CoST comprises both time domain and frequency domain contrastive losses to learn discriminative trend and seasonal representations, respectively. Extensive experiments on real-world datasets show that CoST consistently outperforms the state-of-the-art methods by a considerable margin, achieving a 21.3% improvement in MSE on multivariate benchmarks. It is also robust to various choices of backbone encoders, as well as downstream regressors. Code is available at https://github.com/salesforce/CoST.","url_abs":"https://arxiv.org/abs/2202.01575v3","url_pdf":"https://arxiv.org/pdf/2202.01575v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"cost-contrastive-learning-of-disentangled-1","repo_url":"https://github.com/salesforce/CoST","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"contrastive-learning","task_name":"Contrastive Learning"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"time-series-1","task_name":"Time Series"},{"task_slug":"time-series","task_name":"Time Series Analysis"},{"task_slug":"time-series-forecasting","task_name":"Time Series Forecasting"}],"methods":[{"method_slug":"contrastive-learning","method_name":"Contrastive Learning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2202.01575","atlas_url":"https://app.syntology.ai/?focus=2202.01575","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2202.01575"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/salesforce/CoST","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"ran_draft_wrong":3,"ran":1,"ran_violates":2,"ran_fixture":1,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"a4750195b8805692","entry":"cal_metrics","repo":"salesforce/CoST","repo_kind":"official","path":"tasks/forecasting.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/tasks/forecasting.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a4750195b8805692"}},{"code_sha256_prefix":"1d3809217bd3608f","entry":"fit_ridge","repo":"salesforce/CoST","repo_kind":"official","path":"tasks/_eval_protocols.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/tasks/_eval_protocols.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"1d3809217bd3608f"}},{"code_sha256_prefix":"fd10054ec4772b80","entry":"generate_binomial_mask","repo":"salesforce/CoST","repo_kind":"official","path":"models/encoder.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/models/encoder.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"fd10054ec4772b80"}},{"code_sha256_prefix":"acda587a1d1be3bf","entry":"generate_continuous_mask","repo":"salesforce/CoST","repo_kind":"official","path":"models/encoder.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/models/encoder.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"acda587a1d1be3bf"}},{"code_sha256_prefix":"5254eb44ce12370e","entry":"pad_nan_to_target","repo":"salesforce/CoST","repo_kind":"official","path":"utils.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"5254eb44ce12370e"}},{"code_sha256_prefix":"645d1fdb1dc0e80c","entry":"pkl_load","repo":"salesforce/CoST","repo_kind":"official","path":"utils.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"645d1fdb1dc0e80c"}},{"code_sha256_prefix":"79783deb10f33397","entry":"torch_pad_nan","repo":"salesforce/CoST","repo_kind":"official","path":"utils.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"79783deb10f33397"}},{"code_sha256_prefix":"a0b497709017e0db","entry":"eval_forecasting","repo":"salesforce/CoST","repo_kind":"official","path":"tasks/forecasting.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/tasks/forecasting.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a0b497709017e0db"}},{"code_sha256_prefix":"63e193a1a856ae88","entry":"generate_pred_samples","repo":"salesforce/CoST","repo_kind":"official","path":"tasks/forecasting.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/tasks/forecasting.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"63e193a1a856ae88"}},{"code_sha256_prefix":"3dc27cba7950c088","entry":"load_forecast_csv","repo":"salesforce/CoST","repo_kind":"official","path":"datautils.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/datautils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"3dc27cba7950c088"}},{"code_sha256_prefix":"ee0abcf391ea662f","entry":"load_forecast_npy","repo":"salesforce/CoST","repo_kind":"official","path":"datautils.py","file_url":"https://github.com/salesforce/CoST/blob/HEAD/datautils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"ee0abcf391ea662f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}