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
10c5abb2
Unverified
Commit
10c5abb2
authored
Jul 10, 2022
by
Malinda
Committed by
GitHub
Jul 11, 2022
Browse files
Few optimizations with numpy (#4982)
parent
4e71ed62
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
11 deletions
+8
-11
examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_mlp.py
...tomlbenchmark/nni/extensions/NNI/architectures/run_mlp.py
+1
-1
examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_random_forest.py
...ark/nni/extensions/NNI/architectures/run_random_forest.py
+1
-1
examples/trials/kaggle-tgs-salt/metrics.py
examples/trials/kaggle-tgs-salt/metrics.py
+1
-1
nni/algorithms/compression/v2/pytorch/pruning/tools/task_generator.py
...ms/compression/v2/pytorch/pruning/tools/task_generator.py
+4
-7
nni/algorithms/hpo/ppo_tuner/ppo_tuner.py
nni/algorithms/hpo/ppo_tuner/ppo_tuner.py
+1
-1
No files found.
examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_mlp.py
View file @
10c5abb2
...
...
@@ -117,7 +117,7 @@ def run_mlp(dataset, config, tuner, log):
# Here score is the output of score() from the estimator
cur_score
=
cross_val_score
(
cur_model
,
X_train
,
y_train
)
cur_score
=
sum
(
cur_score
)
/
float
(
le
n
(
cur_score
)
)
cur_score
=
np
.
mea
n
(
cur_score
)
if
np
.
isnan
(
cur_score
):
cur_score
=
0
...
...
examples/trials/benchmarking/automlbenchmark/nni/extensions/NNI/architectures/run_random_forest.py
View file @
10c5abb2
...
...
@@ -138,7 +138,7 @@ def run_random_forest(dataset, config, tuner, log):
# Here score is the output of score() from the estimator
cur_score
=
cross_val_score
(
cur_model
,
X_train
,
y_train
)
cur_score
=
sum
(
cur_score
)
/
float
(
le
n
(
cur_score
)
)
cur_score
=
np
.
mea
n
(
cur_score
)
if
np
.
isnan
(
cur_score
):
cur_score
=
0
...
...
examples/trials/kaggle-tgs-salt/metrics.py
View file @
10c5abb2
...
...
@@ -66,7 +66,7 @@ def compute_eval_metric(gt, predictions):
thresholds
=
[
0.5
,
0.55
,
0.6
,
0.65
,
0.7
,
0.75
,
0.8
,
0.85
,
0.9
,
0.95
]
ious
=
compute_ious
(
gt
,
predictions
)
precisions
=
[
compute_precision_at
(
ious
,
th
)
for
th
in
thresholds
]
return
sum
(
precisions
)
/
le
n
(
precisions
)
return
np
.
mea
n
(
precisions
)
def
intersection_over_union
(
y_true
,
y_pred
):
...
...
nni/algorithms/compression/v2/pytorch/pruning/tools/task_generator.py
View file @
10c5abb2
...
...
@@ -260,13 +260,10 @@ class SimulatedAnnealingTaskGenerator(TaskGenerator):
num_weights
=
sorted
([
self
.
weights_numel
[
op_name
]
for
op_name
in
op_names
])
sparsity
=
sorted
(
random_sparsity
)
total_weights
=
0
total_weights_pruned
=
0
# calculate the scale
for
idx
,
num_weight
in
enumerate
(
num_weights
)
:
total_weights
+=
num_weight
total_weights_pruned
+=
int
(
num_weight
*
sparsity
[
idx
])
total_weights
=
np
.
sum
(
num_weights
)
total_weights
_pruned
=
np
.
sum
([
int
(
num_weight
*
sparsity
[
idx
])
for
idx
,
num_weight
in
enumerate
(
num_weights
)])
if
total_weights_pruned
==
0
:
return
None
...
...
nni/algorithms/hpo/ppo_tuner/ppo_tuner.py
View file @
10c5abb2
...
...
@@ -633,7 +633,7 @@ class PPOTuner(Tuner):
# use mean of finished trials as the result of this failed trial
values
=
[
val
for
val
in
self
.
trials_result
if
val
is
not
None
]
logger
.
warning
(
'In trial_end, values: %s'
,
values
)
self
.
trials_result
[
trial_info_idx
]
=
(
sum
(
values
)
/
le
n
(
values
))
if
values
else
0
self
.
trials_result
[
trial_info_idx
]
=
(
np
.
mea
n
(
values
))
if
values
else
0
self
.
finished_trials
+=
1
if
self
.
finished_trials
==
self
.
inf_batch_size
:
logger
.
debug
(
'Start next round inference in trial_end'
)
...
...
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