-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG + 2] FIX avoid memory cost when sampling from large parameter grids #4840
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
Conversation
Now MRG. Open for review. |
# Try the next grid | ||
ind -= modulo[0] | ||
else: | ||
offsets = ind // modulo[1:] % sizes |
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.
not sure if there is a helpful comment that can be done on this line. took me a minute but alright.
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.
Well yes, I guess the code is unnecessarily obfuscating seeing as the numbers are small so efficiency is little concern. I'd initially thought I'd memoize the modulo arrays, but that seems overkill. I'll rewrite more legibly.
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.
Please give this another quick look to see if it needs further clarification.
Looks good apart from the fact that I'm not 100% sure the tests is non-vacuous. |
thanks for the fix :) |
lgtm. |
great, thanks! On 10 June 2015 at 07:10, Andreas Mueller notifications@github.com wrote:
|
@jnothman super cool 👍 Thanks for the quick fix!, nice and elegant |
Another review? |
|
||
Returns | ||
------- | ||
params : dict of string to any |
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.
what does it mean?
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.
The same description is used above in object constructor. It means "a dict mapping strings to arbitrary-type values".
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.
ok my bad
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.
not bad at all!
looks good |
for sub_grid in self.param_grid: | ||
# XXX: could memoize information used here | ||
if not sub_grid: | ||
if ind == 0: |
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.
Is this branch covered by the test? It looks to me like the test doesn't cover subgrids.
Nevermind, somehow I missed that line. But I still would like a test where a non-empty subgrid follows an empty subgrid, for the else
below.
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.
done
@vene mrg? |
Looks good to me 👍 |
[MRG] FIX avoid memory cost when sampling from large parameter grids
Thanks, @chausler for reporting, and to the reviewers! |
Solve the issue reported at #3850 (comment) by making
ParameterGrid
able to dynamically look up a param setting by index; i.e. list of all possible settings is never realised.Needs: