mblondel / soft-dtw

Python implementation of soft-DTW.
BSD 2-Clause "Simplified" License
550 stars 98 forks source link

Add Sakoe-Chiba band constraint #9

Open TomDLT opened 6 years ago

TomDLT commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.