Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
afe00e46
Unverified
Commit
afe00e46
authored
May 13, 2022
by
liuzhe-lz
Committed by
GitHub
May 13, 2022
Browse files
add optimize mode to random and grid search for webui (#4856)
Co-authored-by:
liuzhe
<
zhliu1@microsoft.com
>
parent
288dcb65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
nni/algorithms/hpo/gridsearch_tuner.py
nni/algorithms/hpo/gridsearch_tuner.py
+4
-1
nni/algorithms/hpo/random_tuner.py
nni/algorithms/hpo/random_tuner.py
+7
-2
No files found.
nni/algorithms/hpo/gridsearch_tuner.py
View file @
afe00e46
...
@@ -88,7 +88,7 @@ class GridSearchTuner(Tuner):
...
@@ -88,7 +88,7 @@ class GridSearchTuner(Tuner):
config.tuner.name = 'GridSearch'
config.tuner.name = 'GridSearch'
"""
"""
def
__init__
(
self
):
def
__init__
(
self
,
optimize_mode
=
None
):
self
.
space
=
None
self
.
space
=
None
# the grid to search in this epoch
# the grid to search in this epoch
...
@@ -116,6 +116,9 @@ class GridSearchTuner(Tuner):
...
@@ -116,6 +116,9 @@ class GridSearchTuner(Tuner):
# dumped JSON string of all tried parameters
# dumped JSON string of all tried parameters
self
.
history
=
set
()
self
.
history
=
set
()
if
optimize_mode
is
not
None
:
_logger
.
info
(
f
'Ignored optimize_mode "
{
optimize_mode
}
"'
)
def
update_search_space
(
self
,
space
):
def
update_search_space
(
self
,
space
):
self
.
space
=
format_search_space
(
space
)
self
.
space
=
format_search_space
(
space
)
if
not
self
.
space
:
# the tuner will crash in this case, report it explicitly
if
not
self
.
space
:
# the tuner will crash in this case, report it explicitly
...
...
nni/algorithms/hpo/random_tuner.py
View file @
afe00e46
...
@@ -42,13 +42,15 @@ class RandomTuner(Tuner):
...
@@ -42,13 +42,15 @@ class RandomTuner(Tuner):
The random seed.
The random seed.
"""
"""
def
__init__
(
self
,
seed
:
int
|
None
=
None
):
def
__init__
(
self
,
seed
:
int
|
None
=
None
,
optimize_mode
:
str
|
None
=
None
):
self
.
space
=
None
self
.
space
=
None
if
seed
is
None
:
# explicitly generate a seed to make the experiment reproducible
if
seed
is
None
:
# explicitly generate a seed to make the experiment reproducible
seed
=
np
.
random
.
default_rng
().
integers
(
2
**
31
)
seed
=
np
.
random
.
default_rng
().
integers
(
2
**
31
)
self
.
rng
=
np
.
random
.
default_rng
(
seed
)
self
.
rng
=
np
.
random
.
default_rng
(
seed
)
self
.
dedup
=
None
self
.
dedup
=
None
_logger
.
info
(
f
'Using random seed
{
seed
}
'
)
_logger
.
info
(
f
'Using random seed
{
seed
}
'
)
if
optimize_mode
is
not
None
:
_logger
.
info
(
f
'Ignored optimize_mode "
{
optimize_mode
}
"'
)
def
update_search_space
(
self
,
space
):
def
update_search_space
(
self
,
space
):
self
.
space
=
format_search_space
(
space
)
self
.
space
=
format_search_space
(
space
)
...
@@ -64,7 +66,10 @@ class RandomTuner(Tuner):
...
@@ -64,7 +66,10 @@ class RandomTuner(Tuner):
class
RandomClassArgsValidator
(
ClassArgsValidator
):
class
RandomClassArgsValidator
(
ClassArgsValidator
):
def
validate_class_args
(
self
,
**
kwargs
):
def
validate_class_args
(
self
,
**
kwargs
):
schema
.
Schema
({
schema
.
Optional
(
'seed'
):
int
}).
validate
(
kwargs
)
schema
.
Schema
({
schema
.
Optional
(
'optimize_mode'
):
str
,
schema
.
Optional
(
'seed'
):
int
,
}).
validate
(
kwargs
)
def
suggest
(
rng
,
space
):
def
suggest
(
rng
,
space
):
params
=
{}
params
=
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment