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

Add Sakoe-Chiba band constraint #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TomDLT
Copy link

@TomDLT TomDLT commented Mar 23, 2018

This PR adds a Sakoe-Chiba band constraint [1], which constrains the path to stay in a band around the diagonal. For now it works only on squared DTW problems.


[1] Sakoe, H., & Chiba, S. (1978). Dynamic programming algorithm optimization for spoken word recognition. IEEE transactions on acoustics, speech, and signal processing, 26(1), 43-49.

@mblondel
Copy link
Owner

This looks very good. Do you use it for speed up or regularization?

I think you could also test the forward pass as follows: use gen_all_paths to generate all paths, filter out those outside of the band and compute the softmin among those. See

https://github.com/mblondel/soft-dtw/blob/master/sdtw/tests/test_soft_dtw.py#L32

for an example.

@TomDLT
Copy link
Author

TomDLT commented Mar 26, 2018

This looks very good. Do you use it for speed up or regularization?

Both, but I use it mostly for speed, since it goes from O(N * N) to O(N * B) where B is the band width.

I think you could also test the forward pass as follows: use gen_all_paths to generate all paths, filter out those outside of the band and compute the softmin among those.

Good point, will do.

sdtw/soft_dtw.py Outdated
self.sakoe_chiba_band = sakoe_chiba_band

if sakoe_chiba_band >= 0:
assert self.D.shape[0] == self.D.shape[1]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question before merge... Why do you need this restriction?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity.
I updated the code and removed the restriction.

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

Successfully merging this pull request may close these issues.

None yet

2 participants