{"id":13688951,"url":"https://github.com/mblondel/soft-dtw","last_synced_at":"2025-10-23T17:20:38.965Z","repository":{"id":57469158,"uuid":"93255712","full_name":"mblondel/soft-dtw","owner":"mblondel","description":"Python implementation of soft-DTW.","archived":false,"fork":false,"pushed_at":"2024-06-19T17:52:43.000Z","size":27,"stargazers_count":559,"open_issues_count":16,"forks_count":98,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-03T16:11:13.917Z","etag":null,"topics":["dtw","dynamic-time-warping","neural-networks","soft-dtw","time-series"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mblondel.png","metadata":{"files":{"readme":"README.rst","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":"2017-06-03T15:08:57.000Z","updated_at":"2025-04-03T03:32:48.000Z","dependencies_parsed_at":"2024-11-14T00:00:34.145Z","dependency_job_id":"c5fe2667-d83d-4807-87f1-88d5b45befa2","html_url":"https://github.com/mblondel/soft-dtw","commit_stats":{"total_commits":30,"total_committers":1,"mean_commits":30.0,"dds":0.0,"last_synced_commit":"1774bcd007acf22dfdb2a596944186d56ac434a6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mblondel%2Fsoft-dtw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mblondel%2Fsoft-dtw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mblondel%2Fsoft-dtw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mblondel%2Fsoft-dtw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mblondel","download_url":"https://codeload.github.com/mblondel/soft-dtw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590951,"owners_count":21129919,"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":["dtw","dynamic-time-warping","neural-networks","soft-dtw","time-series"],"created_at":"2024-08-02T15:01:28.649Z","updated_at":"2025-10-23T17:20:33.926Z","avatar_url":"https://github.com/mblondel.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":".. -*- mode: rst -*-\n\nsoft-DTW\n=========\n\nPython implementation of soft-DTW.\n\nWhat is it?\n-----------\n\nThe celebrated dynamic time warping (DTW) [1] defines the discrepancy between\ntwo time series, of possibly variable length, as their minimal alignment cost.\nAlthough the number of possible alignments is exponential in the length of the\ntwo time series, [1] showed that DTW can be computed in only quadractic time\nusing dynamic programming.\n\nSoft-DTW [2] proposes to replace this minimum by a soft minimum. Like the\noriginal DTW, soft-DTW can be computed in quadratic time using dynamic\nprogramming. However, the main advantage of soft-DTW stems from the fact that\nit is differentiable everywhere and that its gradient can also be computed in\nquadratic time. This enables to use soft-DTW for time series averaging or as a\nloss function, between a ground-truth time series and a time series predicted\nby a neural network, trained end-to-end using backpropagation.\n\nSupported features\n------------------\n\n* soft-DTW (forward pass) and gradient (backward pass) computations,\n  implemented in Cython for speed\n* barycenters (time series averaging)\n* dataset loader for the `UCR archive \u003chttp://www.cs.ucr.edu/~eamonn/time_series_data/\u003e`_\n* `Chainer \u003chttp://chainer.org\u003e`_ function \n\nExample\n--------\n\n.. code-block:: python\n\n    from sdtw import SoftDTW\n    from sdtw.distance import SquaredEuclidean\n\n    # Time series 1: numpy array, shape = [m, d] where m = length and d = dim\n    X = ...\n    # Time series 2: numpy array, shape = [n, d] where n = length and d = dim\n    Y = ...\n\n    # D can also be an arbitrary distance matrix: numpy array, shape [m, n]\n    D = SquaredEuclidean(X, Y)\n    sdtw = SoftDTW(D, gamma=1.0)\n    # soft-DTW discrepancy, approaches DTW as gamma -\u003e 0\n    value = sdtw.compute()\n    # gradient w.r.t. D, shape = [m, n], which is also the expected alignment matrix\n    E = sdtw.grad()\n    # gradient w.r.t. X, shape = [m, d]\n    G = D.jacobian_product(E)\n\nInstallation\n------------\n\nBinary packages are not available.\n\nThis project can be installed from its git repository. It is assumed that you\nhave a working C compiler.\n\n1. Obtain the sources by::\n\n    git clone https://github.com/mblondel/soft-dtw.git\n\nor, if `git` is unavailable, `download as a ZIP from GitHub \u003chttps://github.com/mblondel/soft-dtw/archive/master.zip\u003e`_.\n\n\n2. Install the dependencies::\n\n    # via pip\n\n    pip install numpy scipy scikit-learn cython nose\n\n\n    # via conda\n\n    conda install numpy scipy scikit-learn cython nose\n\n\n3. Build and install soft-dtw::\n\n    cd soft-dtw\n    make cython\n    python setup.py build\n    sudo python setup.py install\n\n\nReferences\n----------\n\n.. [1] Hiroaki Sakoe, Seibi Chiba.\n       *Dynamic programming algorithm optimization for spoken word recognition.*\n       In: IEEE Trans. on Acoustics, Speech, and Sig. Proc, 1978.\n\n.. [2] Marco Cuturi, Mathieu Blondel.\n       *Soft-DTW: a Differentiable Loss Function for Time-Series.*\n       In: Proc. of ICML 2017.\n       [`PDF \u003chttps://arxiv.org/abs/1703.01541\u003e`_]\n\nAuthor\n------\n\n- Mathieu Blondel, 2017\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmblondel%2Fsoft-dtw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmblondel%2Fsoft-dtw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmblondel%2Fsoft-dtw/lists"}