-
-
Notifications
You must be signed in to change notification settings - Fork 990
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
Gather mask of None parameter in TPESampler #3886
Conversation
@HideakiImamura Although I haven't modified the test yet, could you briefly check if this strategy is okay when you have time? By this PR, |
This pull request has not seen any recent activity. |
Thanks for the PR. I think this PR is good to reduce the complexity of TPESampler. Could you fix the CI errors? |
Thanks! I fixed the error. Could you take a look again and assign another reviewer? |
Codecov Report
@@ Coverage Diff @@
## master #3886 +/- ##
==========================================
+ Coverage 90.09% 90.11% +0.02%
==========================================
Files 162 162
Lines 12734 12742 +8
==========================================
+ Hits 11473 11483 +10
+ Misses 1261 1259 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This pull request has not seen any recent activity. |
Let me reassign reviewers since this PR has no recent activities and Imamura-san will take a vacation. @contramundum53 Could you review this PR? |
This pull request has not seen any recent activity. |
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.
LGTM!
This pull request has not seen any recent activity. |
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.
Sorry for the delayed review. I reviewed changes and leave some comments.
optuna/samplers/_tpe/sampler.py
Outdated
param_mask = ~np.isnan(list(config_values.values())[0]) | ||
param_mask_below, param_mask_above = param_mask[indices_below], param_mask[indices_above] | ||
below = {k: v[indices_below[param_mask_below]] for k, v in config_values.items()} | ||
above = {k: v[indices_above[param_mask_above]] for k, v in config_values.items()} |
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.
As written in L458, values
variable is a dictionary that contains only a single hyperparameter, right?
If so, I'd say we can remove L458 and replace these lines like the following.
config_value = values["param_name"]
param_mask = ~np.isnan(config_value)
param_mask_below, param_mask_above = param_mask[indices_below], param_mask[indices_above]
below = config_value[indices_below[param_mask_below]]
above = config_value[indices_above[param_mask_above]]
What do you think?
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.
Sure, I fixed it: 527d5fb.
optuna/samplers/_tpe/sampler.py
Outdated
# In the call of `sample_relative`, this logic makes sense because we only have the | ||
# intersection search space or group decomposed search space. This means one parameter | ||
# misses the one trial, then the other parameter must miss the trial, in this call of | ||
# `sample_relative`. |
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.
This comment seems to have been added in #2688 to indicate that list(config_values.values())[0]
is the correct logic.
But honestly, I don't understand what "This means one parameter misses the one trial, then the other parameter must miss the trial" means. Can you please tell me what kind of search space would include True in the param_mask? More specifically, what objective function would cause the this condition to be false?
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.
Thanks for the comment. I investigated that issue and changed the previous behavior by #4079 to make it consistent with multivariate=False
.
Now, that should happen in a dynamic search space when group=True
.
This pull request has not seen any recent activity. |
This pull request has not seen any recent activity. |
This pull request was closed automatically because it had not seen any recent activity. If you want to discuss it, you can reopen it freely. |
Thanks! Let me assign @contramundum53 again. |
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 new code is easier to read for me. LGTM!
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.
LGTM:+1:
Motivation
Previously, in TPESampler, the mask of removing None parameters (= parameters that do not appear in the trial) was taken in two different places, which can easily cause bugs.
Description of the changes
_build_observation_dict
and_calculate_weights_below_for_multi_objective
(as a consequence,build_observation_dict
was removed).