Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute SoftDTWLossPyTorch with normalization option and time series of different lengths #473

Open
denisbeslic opened this issue Aug 1, 2023 · 1 comment
Labels

Comments

@denisbeslic
Copy link

Describe the bug
Hello, I want to use the SoftDTWLoss with normalization (Soft-DTW divergence) for comparing predicted time series of different length. It seems to throw this error.

  File ".../lib/python3.10/site-packages/tslearn/metrics/soft_dtw_loss_pytorch.py", line 146, in forward
    xxy = torch.cat([x, x, y])

RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 99 but got size 100 for tensor number 2 in the list.

Is it possible to generate a SoftDTWLoss for time series with unequal lengths or is this a bug?

To Reproduce

targets = torch.tensor(np.random.randn(16, 100, 1))
prediction = torch.tensor(np.random.randn(16, 99, 1))
loss_func = SoftDTWLossPyTorch(gamma=1.0, normalize=True, dist_func=None)
loss = loss_func(prediction, targets)
print(loss.shape)
print(loss)

Environment (please complete the following information):

  • OS: Ubuntu 20.04.5 LTS
  • tslearn version 0.6.1

Additional context

@YannCabanes
Copy link
Contributor

Hello @denisbeslic, thanks a lot for reporting this bug!
I am dealing with this issue in PR #478.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants