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
ea89e232
Commit
ea89e232
authored
Aug 21, 2019
by
Yuge Zhang
Committed by
Guoxin
Aug 21, 2019
Browse files
refactor get_current_parameter to avoid using trial._params (#1458)
parent
427f1256
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
4 deletions
+6
-4
src/sdk/pynni/nni/nas_utils.py
src/sdk/pynni/nni/nas_utils.py
+2
-2
src/sdk/pynni/nni/smartparam.py
src/sdk/pynni/nni/smartparam.py
+1
-1
src/sdk/pynni/nni/trial.py
src/sdk/pynni/nni/trial.py
+3
-1
No files found.
src/sdk/pynni/nni/nas_utils.py
View file @
ea89e232
...
...
@@ -32,7 +32,7 @@ def classic_mode(
'''Execute the chosen function and inputs directly.
In this mode, the trial code is only running the chosen subgraph (i.e., the chosen ops and inputs),
without touching the full model graph.'''
if
trial
.
_params
is
None
:
if
trial
.
get_current_parameter
()
is
None
:
trial
.
get_next_parameter
()
mutable_block
=
trial
.
get_current_parameter
(
mutable_id
)
chosen_layer
=
mutable_block
[
mutable_layer_id
][
"chosen_layer"
]
...
...
@@ -118,7 +118,7 @@ def oneshot_mode(
The difference is that oneshot mode does not receive subgraph.
Instead, it uses dropout to randomly dropout inputs and ops.'''
# NNI requires to get_next_parameter before report a result. But the parameter will not be used in this mode
if
trial
.
_params
is
None
:
if
trial
.
get_current_parameter
()
is
None
:
trial
.
get_next_parameter
()
optional_inputs
=
list
(
optional_inputs
.
values
())
inputs_num
=
len
(
optional_inputs
)
...
...
src/sdk/pynni/nni/smartparam.py
View file @
ea89e232
...
...
@@ -189,6 +189,6 @@ else:
raise
RuntimeError
(
'Unrecognized mode: %s'
%
mode
)
def
_get_param
(
key
):
if
trial
.
_params
is
None
:
if
trial
.
get_current_parameter
()
is
None
:
trial
.
get_next_parameter
()
return
trial
.
get_current_parameter
(
key
)
src/sdk/pynni/nni/trial.py
View file @
ea89e232
...
...
@@ -50,10 +50,12 @@ def get_next_parameter():
return
None
return
_params
[
'parameters'
]
def
get_current_parameter
(
tag
):
def
get_current_parameter
(
tag
=
None
):
global
_params
if
_params
is
None
:
return
None
if
tag
is
None
:
return
_params
[
'parameters'
]
return
_params
[
'parameters'
][
tag
]
def
get_experiment_id
():
...
...
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