-
Notifications
You must be signed in to change notification settings - Fork 935
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
DTW #323
DTW #323
Conversation
Nice. I can take a look at this in May. |
I know this is still WIP and commenting at this stage is annoying, but can we not make numba a requirement? This comment provides a workaround for optional jit compilation, so that the same code should work with or without numba. |
This PR is failing tests because of a broken comparison test in the display module. I just fixed this upstream, so if you git rebase master, it should be fixed. |
Done. Should this go into 0.4.3? I think it could go but if we decide that the function interfaces are fine. Putting more features into it later is easy then. |
If you think we can do it quickly (ie next couple of weeks), then sure. If not, we can continue to punt it. |
@stefan-balke Any thoughts on this? I'm fine either way, but if you don't have time to finish it soon, let's punt. |
Yeah, still interested in helping, and I will have more bandwidth to help later this month. |
Ok, I've reassigned #298 to 0.5 then. |
fyi: This is on my next week's list. |
Alright, I got most of the things done. Gullying@craffel can we talk about the gullying? In the case of allowing gullying at the beginning 3 frames, we could simply init D's first row with:
and for the ending frames in a similar way. Display function@bmcfee with the rewrite of the display module, I'm confused where to put the visualizations. I need two things:
Could look like this:
Should I do own functions for this or should it derive from anything in the display module? |
I don't think we necessarily need special case display functions for this. What's wrong with the following (matching your notation)? >>> librosa.display.specshow(C)
>>> plt.plot(p_adj[:, 0], p_adj[:, 1], label='Optimal path') Or, if you want time axes: >>> librosa.display.specshow(C, x_axis='time', y_axis='time')
>>> p_time = librosa.frames_to_time(p_adj)
>>> plt.plot(p_time[:, 0], p_time[:, 1], label='Optimal path') |
Nothing, |
No, I don't think so. I don't think we're on the same page. The gully simply constrains the possible end points. For example, if the distance matrix is of shape (100, 200) and the gully was .9 then the path would have to end any of (90, 199) through (99, 199) or (99, 180) through (99, 199). Does that make sense? I have definitions of it more rigorously in any of my papers which use DTW. So, it's something I usually enforce at traceback time, not in the distance matrix, although I'd expect you could also do it by filling portions of the final row and column of the matrix with infinity. I don't see how it could be accomplished by modifying the first row or column because in my understanding it is independent of the first row and column, it's only a constraint on the final point. BTW, this is something I picked up (and maybe reinterpreted/bastardized) from @dpwe, not sure where he got it from. |
Also, thanks for all of this! I will spend some time checking it out in the near future. |
Hey Colin,
Yep, thought about this and got to the same conclusion :) However, I wonder if we couldn't accomplish this by restricting the subsequence DTW somehow. Here a small sketch: So for me, gullying live somewhat in between subsequence and global DTW but I'll think about it a little bit more... |
Could we get some equations (or pointers/screenshots to relevant papers) to describe what "gullying" means? If @stefan-balke's drawing (c) is accurate, it seems like you could enforce this by, as @craffel says, filling the top row (outside the red box) and right column (outside the green box) by infinity, and the rest fixes itself. |
Firs things first, what I originally wrote
is wrong for subsequence DTW, I wrote it in haste. For subsequence DTW, it should be "the path would have to end any of (90, 199) through (99, 199) or (99, 90) through (99, 199)".
Your sketch looks reasonable to me.
As I said above, I have definitions in my papers which use DTW (and they all say basically the same thing, and it's something I picked up from @dpwe, not sure where he got it from. Here's one from ISMIR 2015 (note this definition is not for subsequence DTW): For subsequence DTW it's |
Anyone in for a CR? We can add gullying when @craffel has more cycles.. |
I'm happy to CR after it passes on travis. |
Oops, it was passing in 3.5. I think we need numba in the dependencies...Tried to add it but it seems it's not used in Travis.
|
@@ -11,7 +11,7 @@ conda_create () | |||
conda update -q conda | |||
conda config --add channels pypi | |||
conda info -a | |||
deps='pip numpy scipy pandas requests nose coverage numpydoc matplotlib sphinx scikit-learn seaborn' | |||
deps='pip numpy scipy pandas requests nose coverage numpydoc matplotlib sphinx scikit-learn seaborn numba' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I add numba.
I just wiped the image cache and restarted the build. Hopefully that should do it. But yes, numba needs to be installed via conda to get llvm packages; pip alone won't do it. |
True fact. |
I don't think your travis problems are coming from conda, but instead are due to the way you parameterize the decorator.
EDIT: scratch that; the problem is that when numba can be imported, it returns the jit wrapper as a proper decorator. But when numba can't be imported, it returns a bool, which doesn't work as a decorator. |
Here we go.... |
Yup, but I'm doing something similar. I'm importing the decorator. If it's available - use it - otherwise return the function and do the normal Python thingy.... Tried it locally with a |
Ready for a first CR. |
Review status: 6 of 8 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. .travis_dependencies.sh, line 14 [r10] (raw file):
|
.travis_dependencies.sh, line 14 [r10] (raw file):
|
librosa/core/dtw.py, line 13 [r10] (raw file):
|
Reviewed 1 of 1 files at r18. Comments from Reviewable |
librosa/core/dtw.py, line 13 [r10] (raw file):
|
Review status: 5 of 8 files reviewed at latest revision, 6 unresolved discussions. librosa/core/dtw.py, line 13 [r10] (raw file):
|
librosa/core/dtw.py, line 13 [r10] (raw file):
|
I squashed the commits. This one is ready to go merge. |
Reviewed 1 of 1 files at r10. librosa/core/dtw.py, line 190 [r10] (raw file):
|
Done. |
Review status: 6 of 8 files reviewed at latest revision, 7 unresolved discussions. librosa/core/dtw.py, line 14 [r21] (raw file):
This doesn't actually create a band anymore; it fills values outside the band. Maybe we can find a more appropriate name and/or description? librosa/core/dtw.py, line 28 [r21] (raw file):
This is unclear. Suggest " Comments from Reviewable |
I called the band now |
Review status: 6 of 8 files reviewed at latest revision, 5 unresolved discussions. librosa/core/dtw.py, line 190 [r10] (raw file):
|
Did I miss anything? Otherwise this one is ready. |
Review status: 6 of 8 files reviewed at latest revision, 4 unresolved discussions. librosa/core/dtw.py, line 7 [r23] (raw file):
Use local module names: from ..util.decorators import optional_jit tests/test_dtw.py, line 69 [r19] (raw file):
|
tests/test_dtw.py, line 69 [r19] (raw file):
|
Reviewed 1 of 2 files at r23, 1 of 1 files at r24. tests/test_dtw.py, line 69 [r19] (raw file):
|
Merged. Thanks @stefan-balke ! |
I got all excited only to find I had been unassigned! DAn. On Tuesday, July 26, 2016, Brian McFee notifications@github.com wrote:
|
Hey all,
I mainly took @craffel dijtw source code and merged it with mine.
As dicussed in #298, we want the following features:
GullyingAfter finishing the features (which are in dijtw), we need more tests and some final notebook with benchmarking the implementation against "vanilla-vanilla" dtw.
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)