Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
4dc8c032
Unverified
Commit
4dc8c032
authored
Jun 11, 2021
by
Yuge Zhang
Committed by
GitHub
Jun 11, 2021
Browse files
Make brute-force strategies budget aware (#3805)
parent
95f4c863
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
nni/retiarii/strategy/bruteforce.py
nni/retiarii/strategy/bruteforce.py
+7
-1
No files found.
nni/retiarii/strategy/bruteforce.py
View file @
4dc8c032
...
...
@@ -8,7 +8,7 @@ import random
import
time
from
typing
import
Any
,
Dict
,
List
from
..
import
Sampler
,
submit_models
,
query_available_resources
from
..
import
Sampler
,
submit_models
,
query_available_resources
,
budget_exhausted
from
.base
import
BaseStrategy
from
.utils
import
dry_run_for_search_space
,
get_targeted_model
...
...
@@ -63,6 +63,8 @@ class GridSearch(BaseStrategy):
for
sample
in
grid_generator
(
search_space
,
shuffle
=
self
.
shuffle
):
_logger
.
debug
(
'New model created. Waiting for resource. %s'
,
str
(
sample
))
while
query_available_resources
()
<=
0
:
if
budget_exhausted
():
return
time
.
sleep
(
self
.
_polling_interval
)
submit_models
(
get_targeted_model
(
base_model
,
applied_mutators
,
sample
))
...
...
@@ -106,6 +108,8 @@ class Random(BaseStrategy):
model
=
mutator
.
apply
(
model
)
_logger
.
debug
(
'New model created. Applied mutators are: %s'
,
str
(
applied_mutators
))
submit_models
(
model
)
elif
budget_exhausted
():
break
else
:
time
.
sleep
(
self
.
_polling_interval
)
else
:
...
...
@@ -114,5 +118,7 @@ class Random(BaseStrategy):
for
sample
in
random_generator
(
search_space
,
dedup
=
self
.
dedup
):
_logger
.
debug
(
'New model created. Waiting for resource. %s'
,
str
(
sample
))
while
query_available_resources
()
<=
0
:
if
budget_exhausted
():
return
time
.
sleep
(
self
.
_polling_interval
)
submit_models
(
get_targeted_model
(
base_model
,
applied_mutators
,
sample
))
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