{"id":19370226,"url":"https://github.com/bgu-cs-vil/dtan","last_synced_at":"2025-04-09T07:09:46.639Z","repository":{"id":36927320,"uuid":"217350696","full_name":"BGU-CS-VIL/dtan","owner":"BGU-CS-VIL","description":"Official PyTorch implementation for our NeurIPS 2019 paper, Diffeomorphic Temporal Alignment Nets. TensorFlow\\Keras  version is available at tf_legacy branch.","archived":false,"fork":false,"pushed_at":"2024-11-23T08:19:48.000Z","size":9666,"stargazers_count":66,"open_issues_count":2,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T05:08:07.825Z","etag":null,"topics":["alignment","deep-learning","pytorch","temporal-transformer","tensorflow","time-series","time-series-classification","ucr"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BGU-CS-VIL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-24T17:02:34.000Z","updated_at":"2025-03-21T07:27:21.000Z","dependencies_parsed_at":"2025-01-01T18:10:29.747Z","dependency_job_id":"9df11f95-a9c5-44bb-aea5-0912aa9d2bcd","html_url":"https://github.com/BGU-CS-VIL/dtan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGU-CS-VIL%2Fdtan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGU-CS-VIL%2Fdtan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGU-CS-VIL%2Fdtan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BGU-CS-VIL%2Fdtan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BGU-CS-VIL","download_url":"https://codeload.github.com/BGU-CS-VIL/dtan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994122,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alignment","deep-learning","pytorch","temporal-transformer","tensorflow","time-series","time-series-classification","ucr"],"created_at":"2024-11-10T08:14:41.124Z","updated_at":"2025-04-09T07:09:46.618Z","avatar_url":"https://github.com/BGU-CS-VIL.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## While this repo is the official implementation of Diffeomorphic Temporal Alignment Nets (DTAN), the method from our NeurIPS 2019 paper, we strongly encourage you to use the (much better) method from our ICML 2023 paper, [Regularization-free Diffeomorphic Temporal Alignment Nets](https://github.com/BGU-CS-VIL/RF-DTAN) (RF-DTAN). \nFor one thing, RF-DTAN will save you the need to do hyper-parameter tuning, as it requires no regularization over the predicted transformations. \n\n\n# Diffeomorphic Temporal Alignment Nets\n## We moved to PyTorch! \nTensorFlow implementation (old master branch) is available at tf_legacy branch.\n\nRepository for our \u003cb\u003eNeurIPS 2019\u003c/b\u003e paper, [Diffeomorphic Temporal Alignment Nets](https://www.cs.bgu.ac.il/~orenfr/DTAN/ShapiraWeber_NeurIPS_2019.pdf) co-authored by: Ron Shapira Weber, Matan Eyal, Nicki Skafte Detlefsen, Oren Shriki and Oren Freifeld.\n\u003cimg src=\"/figures/dtan_intro_fig.png\" alt=\"DTAN joint alignmnet of ECGFiveDays dataset.\"\u003e\n## Model Architecture\n\u003cimg src=\"/figures/DTAN_detailed_model.png\" alt=\"DTAN Architecture.\"\u003e\n\n## Author of this software\nRon Shapira Weber (email: ronsha@post.bgu.ac.il)\n\n## Requirements\n- Standard Python(\u003e=3.6) packages: numpy, matplotlib, tqdm, seaborn\n- PyTorch \u003e= 1.4\n- tslean == 0.5.2\n- libcpab == 2.0\n- For Nvidia GPU iimplementation: CUDA==11.0 + appropriate cuDNN as well. You can follow the instructions [here](https://pytorch.org/get-started/locally/).\n\n## Operation system: \nFor the native PyTorch implementation (slower), we support all operating systems. \nFor the fast CUDA implementation of libcpab, we only support Linux.\n\n## Installation\nWe recommend installing a [virtual environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) via Anaconda.\nFor instance:\n```\nconda create -n dtan python=3.7 numpy matplotlib seaborn tqdm\n```\n### libcpab\nlicpab [2] is a python package supporting the CPAB transformations [1] in Numpy, Tensorflow and Pytorch.\nFor your convince, we have added a lightweight version of libcpab at DTAN/libcpab. \n\nThat being said, you are still encouraged to install the full package. \n\nInstall [libcpab](https://github.com/SkafteNicki/libcpab) \u003cbr\u003e\nNote 1: you might have to recompile the dynamic libraries under /libcpab/tensorflow/ \u003cbr\u003e\n```\ngit clone https://github.com/SkafteNicki/libcpab\n```\nAdd libcpab to your python path:\n```\nexport PYTHONPATH=$PYTHONPATH:$YOUR_FOLDER_PATH/libcpab\n```\nMake sure libcpab was installed properly (Run one of the demos).\n\n### DTAN\nClone the repository:\n```\ngit clone https://github.com/BGU-CS-VIL/dtan.git\n# move to pytorch branch\ngit checkout pytorch\n```\nAdd DTAN to your python path:\n```\nexport PYTHONPATH=$PYTHONPATH:$YOUR_FOLDER_PATH/dtan\n```\nTry the example code under dtan/exmaples (see also our Usage section below):\n```\npython UCR_alignment.py\n```\n## Usage\n### Examples\n1. To initialize the model:\n\n```python\nfrom DTAN.DTAN_layer import DTAN as dtan_model\n\n# Init model to GPU\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nmodel = dtan_model(signal_len=int, channels=int, tess=[int,], n_recurrence=int,\n                    zero_boundary=bool, device='gpu').to(device)\n```\n\n\nUnder the 'examples' dir you can find example scripts for training and running DTAN time-series joint alignment. \n\n2. **UCR time-series classification archive [3] alignment example.** \u003cbr\u003e\nTo run, simply enter (from the examples dir):\n```\npython UCR_alignment.py\n```\nWe support loading data via [tslearn](https://tslearn.readthedocs.io/en/stable/index.html) [4]. \n\nFor more information regarding the UCR archive, please visit:\n[https://www.cs.ucr.edu/~eamonn/time_series_data/](https://www.cs.ucr.edu/~eamonn/time_series_data/)\n\nThe script supports the following flags:\n```\noptional arguments:\n  -h, --help            show this help message and exit\n  --dataset UCR dataset name\n                        string. Dataset name to load from tslearn.datasets.UCR_UEA_datasets\n  --tess_size TESS_SIZE\n                        CPA velocity field partition\n  --smoothness_prior    smoothness prior flag\n  --no_smoothness_prior\n                        no smoothness prior flag\n  --lambda_smooth LAMBDA_SMOOTH\n                        lambda_smooth, larger values -\u003e smoother warps\n  --lambda_var LAMBDA_VAR\n                        lambda_var, larger values -\u003e larger warps\n  --n_recurrences N_RECURRENCES\n                        number of recurrences of R-DTAN\n  --zero_boundary ZERO_BOUNDARY\n                        zero boundary constrain\n  --n_epochs N_EPOCHS   number of epochs\n  --batch_size BATCH_SIZE\n                        batch size\n  --lr LR               learning rate\n\n```\n\n2. **Usage Example - Running with and without smoothness prior**:\u003cbr\u003e\nSee the [jupyter notebook](https://github.com/BGU-CS-VIL/dtan/blob/pytorch/notebooks/Usage%20Example%20-%20Running%20with%20and%20without%20prior.ipynb), illustrating the importance of the smoothness prior. \n\n3. **UCR Nearest Centroid Classification (NCC)**:\n*Coming soon to PyTorch version*\u003cbr\u003e\nHere we provide an end-to-end pipeline for the NCC experiment described in our paper.\nThe script uses the same hyper-parameters (i.e., lambda_var, lambda_smooth, n_recurrences) used in the paper, depending on the UCR dataset. \nTo run the pipeline on the 'ECGFiveDays' dataset go to the 'examples' dir and simply run: \n\n```\npython UCR_NCC.py\n```\nYou can change the dataset inside the script.\n## References\n```\n[1] @article{freifeld2017transformations,\n  title={Transformations Based on Continuous Piecewise-Affine Velocity Fields},\n  author={Freifeld, Oren and Hauberg, Soren and Batmanghelich, Kayhan and Fisher, John W},\n  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},\n  year={2017},\n  publisher={IEEE}\n}\n\n[2] @misc{detlefsen2018,\n  author = {Detlefsen, Nicki S.},\n  title = {libcpab},\n  year = {2018},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/SkafteNicki/libcpab}},\n}\n[3] @misc{UCRArchive,\ntitle={The UCR Time Series Classification Archive},\nauthor={ Chen, Yanping and Keogh, Eamonn and Hu, Bing and Begum, Nurjahan and Bagnall, Anthony and Mueen, Abdullah and Batista, Gustavo},\nyear={2015},\nmonth={July},\nnote = {\\url{www.cs.ucr.edu/~eamonn/time_series_data/}}\n}\n[4] @article{JMLR:v21:20-091,\n  author  = {Romain Tavenard and Johann Faouzi and Gilles Vandewiele and\n             Felix Divo and Guillaume Androz and Chester Holtz and\n             Marie Payne and Roman Yurchak and Marc Ru{\\ss}wurm and\n             Kushal Kolar and Eli Woods},\n  title   = {Tslearn, A Machine Learning Toolkit for Time Series Data},\n  journal = {Journal of Machine Learning Research},\n  year    = {2020},\n  volume  = {21},\n  number  = {118},\n  pages   = {1-6},\n  url     = {http://jmlr.org/papers/v21/20-091.html}\n}\n```\n## Versions:\n\n\n## License\nThis software is released under the MIT License (included with the software). Note, however, that if you are using this code (and/or the results of running it) to support any form of publication (e.g., a book, a journal paper, a conference paper, a patent application, etc.) then we request you will cite our paper:\n```\n@inproceedings{weber2019diffeomorphic,\n  title={Diffeomorphic Temporal Alignment Nets},\n  author={Weber, Ron A Shapira and Eyal, Matan and Skafte, Nicki and Shriki, Oren and Freifeld, Oren},\n  booktitle={Advances in Neural Information Processing Systems},\n  pages={6570--6581},\n  year={2019}\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgu-cs-vil%2Fdtan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgu-cs-vil%2Fdtan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgu-cs-vil%2Fdtan/lists"}