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
487230d8
Unverified
Commit
487230d8
authored
May 20, 2022
by
liuzhe-lz
Committed by
GitHub
May 20, 2022
Browse files
Make TPE import data more robust (#4865)
parent
0ab4916a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
nni/algorithms/hpo/tpe_tuner.py
nni/algorithms/hpo/tpe_tuner.py
+8
-1
No files found.
nni/algorithms/hpo/tpe_tuner.py
View file @
487230d8
...
...
@@ -24,6 +24,7 @@ import numpy as np
from
scipy.special
import
erf
# pylint: disable=no-name-in-module
from
typing_extensions
import
Literal
import
nni
from
nni.common.hpo_utils
import
Deduplicator
,
OptimizeMode
,
format_search_space
,
deformat_parameters
,
format_parameters
from
nni.tuner
import
Tuner
from
nni.utils
import
extract_scalar_reward
...
...
@@ -201,11 +202,17 @@ class TpeTuner(Tuner):
self
.
_running_params
.
pop
(
parameter_id
,
None
)
def
import_data
(
self
,
data
):
# for resuming experiment
if
isinstance
(
data
,
str
):
data
=
nni
.
load
(
data
)
for
trial
in
data
:
if
isinstance
(
trial
,
str
):
trial
=
nni
.
load
(
trial
)
param
=
format_parameters
(
trial
[
'parameter'
],
self
.
space
)
loss
=
trial
[
'value'
]
if
isinstance
(
loss
,
dict
)
and
'default'
in
loss
:
loss
=
loss
[
'default'
]
if
self
.
optimize_mode
is
OptimizeMode
.
Maximize
:
loss
=
-
trial
[
'value'
]
loss
=
-
loss
for
key
,
value
in
param
.
items
():
self
.
_history
[
key
].
append
(
Record
(
value
,
loss
))
_logger
.
info
(
f
'Replayed
{
len
(
data
)
}
trials'
)
...
...
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