pysdtw
Torch implementation of the Soft-DTW algorithm, supports both cpu and CUDA hardware.
Note: This repository started as a fork from this project.
Installation
This package is available on pypi and depends on pytorch and numba.
Install with:
pip install pysdtw
Usage
import pysdtw
# the input data includes a batch dimension
X = torch.rand((10, 5, 7), requires_grad=True)
Y = torch.rand((10, 9, 7))
# optionally choose a pairwise distance function
fun = pysdtw.distance.pairwise_l2_squared
# create the SoftDTW distance function
sdtw = pysdtw.SoftDTW(gamma=1.0, dist_func=fun, use_cuda=False)
# soft-DTW discrepancy, approaches DTW as gamma -> 0
res = sdtw(X, Y)
# define a loss, which gradient can be backpropagated
loss = res.sum()
loss.backward()
# X.grad now contains the gradient with respect to the loss
Metadata
Release files for pysdtw 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pysdtw-0.0.5.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysdtw-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / pysdtw-0.0.5.tar.gz
| Download URL | pysdtw-0.0.5.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1e9a25c250f0da3a886dc7d779e9f3ab8b8cbbdba607427a9fef146b25ae4e8
|
|
BLAKE2b-256 checksum How to use checksums |
517ce201ffa0144916bd2c26a7e5a2d2aeb6f1ecadd89502bdded9d6deb830c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / pysdtw-0.0.5-py3-none-any.whl
| Download URL | pysdtw-0.0.5-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a46d46fb00408a300a2dbe006ea957d3efef20502cc98d24c5b22e3ee867653
|
|
BLAKE2b-256 checksum How to use checksums |
ac0062c234127146cc4695fe2e28fb827c59b4f2d417deb09b9a0c21eb99781f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|