This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
change quniform/qloguniform style in GridSearch to conform with other tuners #1379
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,8 @@ class GridSearchTuner(Tuner): | |
|
||
Type 'choice' will select one of the options. Note that it can also be nested. | ||
|
||
Type 'quniform' will receive three values [low, high, q], where [low, high] specifies a range and 'q' specifies the number of values that will be sampled evenly. | ||
Note that q should be at least 2. | ||
It will be sampled in a way that the first sampled value is 'low', and each of the following values is (high-low)/q larger that the value in front of it. | ||
Type 'quniform' will receive three values [low, high, q], where [low, high] specifies a range and 'q' specifies the interval | ||
It will be sampled in a way that the first sampled value is 'low', and each of the following values is 'interval' larger that the value in front of it. | ||
|
||
Type 'qloguniform' behaves like 'quniform' except that it will first change the range to [log(low), log(high)] | ||
and sample and then change the sampled value back. | ||
|
@@ -95,19 +94,16 @@ def json2parameter(self, ss_spec): | |
|
||
def _parse_quniform(self, param_value): | ||
'''parse type of quniform parameter and return a list''' | ||
if param_value[2] < 2: | ||
raise RuntimeError("The number of values sampled (q) should be at least 2") | ||
low, high, count = param_value[0], param_value[1], param_value[2] | ||
interval = (high - low) / (count - 1) | ||
return [float(low + interval * i) for i in range(count)] | ||
low, high, interval = param_value[0], param_value[1], param_value[2] | ||
count = int(np.floor((high - low) / interval)) + 1 | ||
return [low + interval * i for i in range(count)] | ||
|
||
def parse_qtype(self, param_type, param_value): | ||
'''parse type of quniform or qloguniform''' | ||
if param_type == 'quniform': | ||
return self._parse_quniform(param_value) | ||
if param_type == 'qloguniform': | ||
param_value[:2] = np.log(param_value[:2]) | ||
return list(np.exp(self._parse_quniform(param_value))) | ||
if param_type in ['quniform', 'qloguniform']: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cannot deal with quniform and qloguniform in the same way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the difference ? |
||
# qloguniform has no difference from quniform, | ||
# since grid search does not consider possibility distribution | ||
return self._parse_quniform(param_value) | ||
|
||
raise RuntimeError("Not supported type: %s" % param_type) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
larger than
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.
fixed