-
Notifications
You must be signed in to change notification settings - Fork 3
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
Optimize conditional entropy functions #50
Comments
I've made an optimization that did not actually change run time c91e6cd There were a lot of matrix transposes used to access a single column in an array, when that can be accomplished with a simple column slice. I tested the performance on those operations by themselves, and found that there was a performance increase, but within the context of Even if this didn't help runtime by any measurable means, it most likely helped memory usage a little bit, as the transposed arrays are not being created and stored in memory. It also gave me a chance to test out the unit test script I wrote to help with optimizing, which not only displays run time, but also asserts that behavior is not altered. Subsequent optimizations will be benchmarked with this script. Now to fix the real bottleneck: that return statement. |
Do you have any reason to believe that slices do anything different than
Earl Bellinger On Mon, Dec 15, 2014 at 7:45 PM, Dan Wysocki [email protected]
|
Not that it really matters anyway. Micro-optimization, root of all evil, Earl Bellinger On Mon, Dec 15, 2014 at 7:56 PM, Earl Bellinger [email protected]
|
From my understanding, slicing gives you a view of the existing array, while transposing creates a new array. Either way, it at least seems like better style to take a slice of an array than to transpose it and then slice it. |
So I guess I was wrong, transpose is also a view. I think the performance differences between the two are probably too small to measure, so I'm going to say we should adopt the column slicing approach, just for readability's sake. |
Ok, here's the real performance boost f2d57bc All I changed here was the return line in There is one caveat, though. The way I've done it, I perform the computation over all of the bins, disregarding even if that means dividing by zero. This doesn't change the end behavior, however, because we know in advance the indices where that will occur, and I just overwrite them with zeroes afterwards. This has the annoying side-effect of numpy printing division by zero and invalid operation warnings, which I suppressed. This could back-fire, though, because it suppresses possible other warnings. I would have to ensure the computation only occurs at the indices which do not need to be replaced with 0, which is rather difficult, so for now I'm going to leave these changes in a new function, until I figure out a better way. Here are the performance tests:
|
I've done away with the division by zero issue altogether 4374018 Here are the performance tests:
|
Good jorb. Is this issue solved now? |
I think it should be tested on a sample of OGLE stars, timed, and compared to the results Gabriel got previously. |
possibly now solved? |
Probably. For future reference: the few test cases I tried were giving results consistent with expectations, but Gabriel uncovered test cases that were not. I had introduced a bug, and summed along the wrong axis. To close this issue off, I think we should obtain Gabriel's old results, and confirm that we are now consistent with a random sample of them. |
Here is a tabulation of Gabriel's results, divided into folders for We might expect to see a very small difference, due to numerical error, so we should reproduce these results, take the difference, and make a call as to whether it's tolerable. |
As of now, there are bottlenecks in the CE functions. The biggest one is probably the line
which uses vanilla python iterators to perform a mesh computation, when numpy matrix operations would be much more efficient. Other small optimizations include
which is probably equivalent to
r.shape[0]
, or something similar, andwhich can probably be done without evaluating the lazy iterable into a concrete list.
When I get the chance I will implement these optimizations, as right now conditional entropy runs at an unacceptably slow rate.
The text was updated successfully, but these errors were encountered: