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

Improve gak #514

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add data type specifications for gak to return the same data type tha…
…n its input
  • Loading branch information
YannCabanes committed Apr 4, 2024
commit 48118014f339b7ae266491afa5c0efaf28b67e06
2 changes: 1 addition & 1 deletion tslearn/metrics/softdtw_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _gak(gram, be=None):
gram = be.array(gram)
sz1, sz2 = be.shape(gram)

cum_sum = be.zeros((sz1 + 1, sz2 + 1))
cum_sum = be.zeros((sz1 + 1, sz2 + 1), dtype=gram.dtype)
cum_sum[0, 0] = 1.0

for i in range(sz1):
Expand Down
2 changes: 1 addition & 1 deletion tslearn/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _cdist_generic(
if dataset2 is None:
# Inspired from code by @GillesVandewiele:
# https://github.com/rtavenar/tslearn/pull/128#discussion_r314978479
matrix = be.zeros((len(dataset1), len(dataset1)))
matrix = be.zeros((len(dataset1), len(dataset1)), dtype=dataset1.dtype)
indices = be.triu_indices(
len(dataset1), k=0 if compute_diagonal else 1, m=len(dataset1)
)
Expand Down