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
cd3a912a
Unverified
Commit
cd3a912a
authored
Nov 27, 2019
by
SparkSnail
Committed by
GitHub
Nov 27, 2019
Browse files
Merge pull request #218 from microsoft/master
merge master
parents
a0846f2a
e9cba778
Changes
375
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
95 additions
and
445 deletions
+95
-445
src/sdk/pynni/nni/platform/standalone.py
src/sdk/pynni/nni/platform/standalone.py
+5
-23
src/sdk/pynni/nni/platform/test.py
src/sdk/pynni/nni/platform/test.py
+2
-20
src/sdk/pynni/nni/ppo_tuner/distri.py
src/sdk/pynni/nni/ppo_tuner/distri.py
+3
-19
src/sdk/pynni/nni/ppo_tuner/model.py
src/sdk/pynni/nni/ppo_tuner/model.py
+3
-19
src/sdk/pynni/nni/ppo_tuner/policy.py
src/sdk/pynni/nni/ppo_tuner/policy.py
+3
-19
src/sdk/pynni/nni/ppo_tuner/ppo_tuner.py
src/sdk/pynni/nni/ppo_tuner/ppo_tuner.py
+46
-93
src/sdk/pynni/nni/ppo_tuner/util.py
src/sdk/pynni/nni/ppo_tuner/util.py
+3
-19
src/sdk/pynni/nni/protocol.py
src/sdk/pynni/nni/protocol.py
+2
-19
src/sdk/pynni/nni/recoverable.py
src/sdk/pynni/nni/recoverable.py
+2
-19
src/sdk/pynni/nni/smac_tuner/__init__.py
src/sdk/pynni/nni/smac_tuner/__init__.py
+3
-0
src/sdk/pynni/nni/smac_tuner/convert_ss_to_scenario.py
src/sdk/pynni/nni/smac_tuner/convert_ss_to_scenario.py
+2
-19
src/sdk/pynni/nni/smac_tuner/smac_tuner.py
src/sdk/pynni/nni/smac_tuner/smac_tuner.py
+3
-19
src/sdk/pynni/nni/smartparam.py
src/sdk/pynni/nni/smartparam.py
+2
-20
src/sdk/pynni/nni/trial.py
src/sdk/pynni/nni/trial.py
+2
-20
src/sdk/pynni/nni/tuner.py
src/sdk/pynni/nni/tuner.py
+2
-19
src/sdk/pynni/nni/utils.py
src/sdk/pynni/nni/utils.py
+3
-19
src/sdk/pynni/setup.py
src/sdk/pynni/setup.py
+2
-20
src/sdk/pynni/tests/__init__.py
src/sdk/pynni/tests/__init__.py
+2
-20
src/sdk/pynni/tests/test_assessor.py
src/sdk/pynni/tests/test_assessor.py
+2
-20
src/sdk/pynni/tests/test_builtin_tuners.py
src/sdk/pynni/tests/test_builtin_tuners.py
+3
-19
No files found.
src/sdk/pynni/nni/platform/standalone.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
logging
import
logging
import
json_tricks
import
json_tricks
...
@@ -44,13 +26,13 @@ def get_next_parameter():
...
@@ -44,13 +26,13 @@ def get_next_parameter():
}
}
def
get_experiment_id
():
def
get_experiment_id
():
pass
return
'STANDALONE'
def
get_trial_id
():
def
get_trial_id
():
pass
return
'STANDALONE'
def
get_sequence_id
():
def
get_sequence_id
():
pass
return
0
def
send_metric
(
string
):
def
send_metric
(
string
):
metric
=
json_tricks
.
loads
(
string
)
metric
=
json_tricks
.
loads
(
string
)
...
...
src/sdk/pynni/nni/platform/test.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
# pylint: skip-file
# pylint: skip-file
...
...
src/sdk/pynni/nni/ppo_tuner/distri.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
functions for sampling from hidden state
functions for sampling from hidden state
"""
"""
...
...
src/sdk/pynni/nni/ppo_tuner/model.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
the main model of policy/value network
the main model of policy/value network
"""
"""
...
...
src/sdk/pynni/nni/ppo_tuner/policy.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
build policy/value network from model
build policy/value network from model
"""
"""
...
...
src/sdk/pynni/nni/ppo_tuner/ppo_tuner.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
ppo_tuner.py including:
ppo_tuner.py including:
class PPOTuner
class PPOTuner
...
@@ -367,74 +351,33 @@ class PPOTuner(Tuner):
...
@@ -367,74 +351,33 @@ class PPOTuner(Tuner):
self
.
send_trial_callback
=
None
self
.
send_trial_callback
=
None
logger
.
info
(
'Finished PPOTuner initialization'
)
logger
.
info
(
'Finished PPOTuner initialization'
)
def
_process_one_nas_space
(
self
,
block_name
,
block_space
):
"""
Process nas space to determine observation space and action space
Parameters
----------
block_name : str
The name of the mutable block
block_space : dict
Search space of this mutable block
Returns
-------
actions_spaces : list
List of the space of each action
actions_to_config : list
The mapping from action to generated configuration
"""
actions_spaces
=
[]
actions_to_config
=
[]
block_arch_temp
=
{}
for
l_name
,
layer
in
block_space
.
items
():
chosen_layer_temp
=
{}
if
len
(
layer
[
'layer_choice'
])
>
1
:
actions_spaces
.
append
(
layer
[
'layer_choice'
])
actions_to_config
.
append
((
block_name
,
l_name
,
'chosen_layer'
))
chosen_layer_temp
[
'chosen_layer'
]
=
None
else
:
assert
len
(
layer
[
'layer_choice'
])
==
1
chosen_layer_temp
[
'chosen_layer'
]
=
layer
[
'layer_choice'
][
0
]
if
layer
[
'optional_input_size'
]
not
in
[
0
,
1
,
[
0
,
1
]]:
raise
ValueError
(
'Optional_input_size can only be 0, 1, or [0, 1], but the pecified one is %s'
%
(
layer
[
'optional_input_size'
]))
if
isinstance
(
layer
[
'optional_input_size'
],
list
):
actions_spaces
.
append
([
"None"
,
*
layer
[
'optional_inputs'
]])
actions_to_config
.
append
((
block_name
,
l_name
,
'chosen_inputs'
))
chosen_layer_temp
[
'chosen_inputs'
]
=
None
elif
layer
[
'optional_input_size'
]
==
1
:
actions_spaces
.
append
(
layer
[
'optional_inputs'
])
actions_to_config
.
append
((
block_name
,
l_name
,
'chosen_inputs'
))
chosen_layer_temp
[
'chosen_inputs'
]
=
None
elif
layer
[
'optional_input_size'
]
==
0
:
chosen_layer_temp
[
'chosen_inputs'
]
=
[]
else
:
raise
ValueError
(
'invalid type and value of optional_input_size'
)
block_arch_temp
[
l_name
]
=
chosen_layer_temp
self
.
chosen_arch_template
[
block_name
]
=
block_arch_temp
return
actions_spaces
,
actions_to_config
def
_process_nas_space
(
self
,
search_space
):
def
_process_nas_space
(
self
,
search_space
):
"""
Process nas search space to get action/observation space
"""
actions_spaces
=
[]
actions_spaces
=
[]
actions_to_config
=
[]
actions_to_config
=
[]
for
b_name
,
block
in
search_space
.
items
():
for
key
,
val
in
search_space
.
items
():
if
block
[
'_type'
]
!=
'mutable_layer'
:
if
val
[
'_type'
]
==
'layer_choice'
:
raise
ValueError
(
'PPOTuner only accept mutable_layer type in search space, but the current one is %s'
%
(
block
[
'_type'
]))
actions_to_config
.
append
((
key
,
'layer_choice'
))
block
=
block
[
'_value'
]
actions_spaces
.
append
(
val
[
'_value'
])
act
,
act_map
=
self
.
_process_one_nas_space
(
b_name
,
block
)
self
.
chosen_arch_template
[
key
]
=
None
actions_spaces
.
extend
(
act
)
elif
val
[
'_type'
]
==
'input_choice'
:
actions_to_config
.
extend
(
act_map
)
candidates
=
val
[
'_value'
][
'candidates'
]
n_chosen
=
val
[
'_value'
][
'n_chosen'
]
if
n_chosen
not
in
[
0
,
1
,
[
0
,
1
]]:
raise
ValueError
(
'Optional_input_size can only be 0, 1, or [0, 1], but the pecified one is %s'
%
(
n_chosen
))
if
isinstance
(
n_chosen
,
list
):
actions_to_config
.
append
((
key
,
'input_choice'
))
# FIXME: risk, candidates might also have None
actions_spaces
.
append
([
'None'
,
*
candidates
])
self
.
chosen_arch_template
[
key
]
=
None
elif
n_chosen
==
1
:
actions_to_config
.
append
((
key
,
'input_choice'
))
actions_spaces
.
append
(
candidates
)
self
.
chosen_arch_template
[
key
]
=
None
elif
n_chosen
==
0
:
self
.
chosen_arch_template
[
key
]
=
[]
else
:
raise
ValueError
(
'Unsupported search space type: %s'
%
(
val
[
'_type'
]))
# calculate observation space
# calculate observation space
dedup
=
{}
dedup
=
{}
...
@@ -444,7 +387,6 @@ class PPOTuner(Tuner):
...
@@ -444,7 +387,6 @@ class PPOTuner(Tuner):
full_act_space
=
[
act
for
act
,
_
in
dedup
.
items
()]
full_act_space
=
[
act
for
act
,
_
in
dedup
.
items
()]
assert
len
(
full_act_space
)
==
len
(
dedup
)
assert
len
(
full_act_space
)
==
len
(
dedup
)
observation_space
=
len
(
full_act_space
)
observation_space
=
len
(
full_act_space
)
nsteps
=
len
(
actions_spaces
)
nsteps
=
len
(
actions_spaces
)
return
actions_spaces
,
actions_to_config
,
full_act_space
,
observation_space
,
nsteps
return
actions_spaces
,
actions_to_config
,
full_act_space
,
observation_space
,
nsteps
...
@@ -486,7 +428,7 @@ class PPOTuner(Tuner):
...
@@ -486,7 +428,7 @@ class PPOTuner(Tuner):
Search space for NAS
Search space for NAS
the format could be referred to search space spec (https://nni.readthedocs.io/en/latest/Tutorial/SearchSpaceSpec.html).
the format could be referred to search space spec (https://nni.readthedocs.io/en/latest/Tutorial/SearchSpaceSpec.html).
"""
"""
logger
.
info
(
'
===
update search space %s'
,
search_space
)
logger
.
info
(
'update search space %s'
,
search_space
)
assert
self
.
search_space
is
None
assert
self
.
search_space
is
None
self
.
search_space
=
search_space
self
.
search_space
=
search_space
...
@@ -512,16 +454,19 @@ class PPOTuner(Tuner):
...
@@ -512,16 +454,19 @@ class PPOTuner(Tuner):
chosen_arch
=
copy
.
deepcopy
(
self
.
chosen_arch_template
)
chosen_arch
=
copy
.
deepcopy
(
self
.
chosen_arch_template
)
for
cnt
,
act
in
enumerate
(
actions
):
for
cnt
,
act
in
enumerate
(
actions
):
act_name
=
self
.
full_act_space
[
act
]
act_name
=
self
.
full_act_space
[
act
]
(
block_name
,
layer_name
,
key
)
=
self
.
actions_to_config
[
cnt
]
(
_key
,
_type
)
=
self
.
actions_to_config
[
cnt
]
if
key
==
'chosen_inputs
'
:
if
_type
==
'input_choice
'
:
if
act_name
==
'None'
:
if
act_name
==
'None'
:
chosen_arch
[
block_name
][
layer_name
][
key
]
=
[]
chosen_arch
[
_key
]
=
{
'_value'
:
[],
'_idx'
:
[]
}
else
:
else
:
chosen_arch
[
block_name
][
layer_name
][
key
]
=
[
act_name
]
candidates
=
self
.
search_space
[
_key
][
'_value'
][
'candidates'
]
elif
key
==
'chosen_layer'
:
idx
=
candidates
.
index
(
act_name
)
chosen_arch
[
block_name
][
layer_name
][
key
]
=
act_name
chosen_arch
[
_key
]
=
{
'_value'
:
[
act_name
],
'_idx'
:
[
idx
]}
elif
_type
==
'layer_choice'
:
idx
=
self
.
search_space
[
_key
][
'_value'
].
index
(
act_name
)
chosen_arch
[
_key
]
=
{
'_value'
:
act_name
,
'_idx'
:
idx
}
else
:
else
:
raise
ValueError
(
'unrecognized key: {0}'
.
format
(
key
))
raise
ValueError
(
'unrecognized key: {0}'
.
format
(
_type
))
return
chosen_arch
return
chosen_arch
def
generate_multiple_parameters
(
self
,
parameter_id_list
,
**
kwargs
):
def
generate_multiple_parameters
(
self
,
parameter_id_list
,
**
kwargs
):
...
@@ -577,6 +522,7 @@ class PPOTuner(Tuner):
...
@@ -577,6 +522,7 @@ class PPOTuner(Tuner):
trial_info_idx
,
actions
=
self
.
trials_info
.
get_next
()
trial_info_idx
,
actions
=
self
.
trials_info
.
get_next
()
if
trial_info_idx
is
None
:
if
trial_info_idx
is
None
:
logger
.
debug
(
'Credit added by one in parameters request'
)
self
.
credit
+=
1
self
.
credit
+=
1
self
.
param_ids
.
append
(
parameter_id
)
self
.
param_ids
.
append
(
parameter_id
)
raise
nni
.
NoMoreTrialError
(
'no more parameters now.'
)
raise
nni
.
NoMoreTrialError
(
'no more parameters now.'
)
...
@@ -589,6 +535,7 @@ class PPOTuner(Tuner):
...
@@ -589,6 +535,7 @@ class PPOTuner(Tuner):
"""
"""
Run a inference to generate next batch of configurations
Run a inference to generate next batch of configurations
"""
"""
logger
.
debug
(
'Start next round inference...'
)
self
.
finished_trials
=
0
self
.
finished_trials
=
0
self
.
model
.
compute_rewards
(
self
.
trials_info
,
self
.
trials_result
)
self
.
model
.
compute_rewards
(
self
.
trials_info
,
self
.
trials_result
)
self
.
model
.
train
(
self
.
trials_info
,
self
.
inf_batch_size
)
self
.
model
.
train
(
self
.
trials_info
,
self
.
inf_batch_size
)
...
@@ -600,6 +547,7 @@ class PPOTuner(Tuner):
...
@@ -600,6 +547,7 @@ class PPOTuner(Tuner):
mb_values
,
mb_neglogpacs
,
mb_values
,
mb_neglogpacs
,
mb_dones
,
last_values
,
mb_dones
,
last_values
,
self
.
inf_batch_size
)
self
.
inf_batch_size
)
logger
.
debug
(
'Next round inference complete.'
)
# check credit and submit new trials
# check credit and submit new trials
for
_
in
range
(
self
.
credit
):
for
_
in
range
(
self
.
credit
):
trial_info_idx
,
actions
=
self
.
trials_info
.
get_next
()
trial_info_idx
,
actions
=
self
.
trials_info
.
get_next
()
...
@@ -612,6 +560,7 @@ class PPOTuner(Tuner):
...
@@ -612,6 +560,7 @@ class PPOTuner(Tuner):
new_config
=
self
.
_actions_to_config
(
actions
)
new_config
=
self
.
_actions_to_config
(
actions
)
self
.
send_trial_callback
(
param_id
,
new_config
)
self
.
send_trial_callback
(
param_id
,
new_config
)
self
.
credit
-=
1
self
.
credit
-=
1
logger
.
debug
(
'Send new trial (%d, %s) for reducing credit'
,
param_id
,
new_config
)
def
receive_trial_result
(
self
,
parameter_id
,
parameters
,
value
,
**
kwargs
):
def
receive_trial_result
(
self
,
parameter_id
,
parameters
,
value
,
**
kwargs
):
"""
"""
...
@@ -637,7 +586,10 @@ class PPOTuner(Tuner):
...
@@ -637,7 +586,10 @@ class PPOTuner(Tuner):
self
.
trials_result
[
trial_info_idx
]
=
value
self
.
trials_result
[
trial_info_idx
]
=
value
self
.
finished_trials
+=
1
self
.
finished_trials
+=
1
logger
.
debug
(
'receive_trial_result, parameter_id %d, trial_info_idx %d, finished_trials %d, inf_batch_size %d'
,
parameter_id
,
trial_info_idx
,
self
.
finished_trials
,
self
.
inf_batch_size
)
if
self
.
finished_trials
==
self
.
inf_batch_size
:
if
self
.
finished_trials
==
self
.
inf_batch_size
:
logger
.
debug
(
'Start next round inference in receive_trial_result'
)
self
.
_next_round_inference
()
self
.
_next_round_inference
()
def
trial_end
(
self
,
parameter_id
,
success
,
**
kwargs
):
def
trial_end
(
self
,
parameter_id
,
success
,
**
kwargs
):
...
@@ -666,6 +618,7 @@ class PPOTuner(Tuner):
...
@@ -666,6 +618,7 @@ class PPOTuner(Tuner):
self
.
trials_result
[
trial_info_idx
]
=
(
sum
(
values
)
/
len
(
values
))
if
values
else
0
self
.
trials_result
[
trial_info_idx
]
=
(
sum
(
values
)
/
len
(
values
))
if
values
else
0
self
.
finished_trials
+=
1
self
.
finished_trials
+=
1
if
self
.
finished_trials
==
self
.
inf_batch_size
:
if
self
.
finished_trials
==
self
.
inf_batch_size
:
logger
.
debug
(
'Start next round inference in trial_end'
)
self
.
_next_round_inference
()
self
.
_next_round_inference
()
def
import_data
(
self
,
data
):
def
import_data
(
self
,
data
):
...
...
src/sdk/pynni/nni/ppo_tuner/util.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
util functions
util functions
"""
"""
...
...
src/sdk/pynni/nni/protocol.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
logging
import
logging
import
threading
import
threading
...
...
src/sdk/pynni/nni/recoverable.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
os
import
os
...
...
src/sdk/pynni/nni/smac_tuner/__init__.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from
.smac_tuner
import
SMACTuner
from
.smac_tuner
import
SMACTuner
src/sdk/pynni/nni/smac_tuner/convert_ss_to_scenario.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
json
import
json
...
...
src/sdk/pynni/nni/smac_tuner/smac_tuner.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
smac_tuner.py
smac_tuner.py
"""
"""
...
...
src/sdk/pynni/nni/smartparam.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
numpy
as
np
import
numpy
as
np
...
...
src/sdk/pynni/nni/trial.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
json_tricks
import
json_tricks
...
...
src/sdk/pynni/nni/tuner.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
"""
"""
Tuner is an AutoML algorithm, which generates a new configuration for the next try.
Tuner is an AutoML algorithm, which generates a new configuration for the next try.
...
...
src/sdk/pynni/nni/utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
"""
"""
utils.py
utils.py
"""
"""
...
...
src/sdk/pynni/setup.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
os
import
os
import
setuptools
import
setuptools
...
...
src/sdk/pynni/tests/__init__.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
os
import
os
...
...
src/sdk/pynni/tests/test_assessor.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
nni.protocol
import
nni.protocol
from
nni.protocol
import
CommandType
,
send
,
receive
from
nni.protocol
import
CommandType
,
send
,
receive
...
...
src/sdk/pynni/tests/test_builtin_tuners.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
glob
import
glob
import
json
import
json
import
logging
import
logging
...
...
Prev
1
…
11
12
13
14
15
16
17
18
19
Next
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