Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
e59587c9
There was a problem fetching the pipeline summary.
Commit
e59587c9
authored
6 years ago
by
Saeed SARFJOO
Browse files
Options
Downloads
Patches
Plain Diff
set sort-by by string
parent
cde558b2
Branches
Branches containing commit
No related tags found
1 merge request
!61
add sort_by_accuracy and max_wait_intervals to eval.py
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/script/eval.py
+8
-8
8 additions, 8 deletions
bob/learn/tensorflow/script/eval.py
with
8 additions
and
8 deletions
bob/learn/tensorflow/script/eval.py
+
8
−
8
View file @
e59587c9
...
...
@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
def
save_n_best_models
(
train_dir
,
save_dir
,
evaluated_file
,
keep_n_best_models
,
sort_by
_accuracy
):
keep_n_best_models
,
sort_by
):
create_directories_safe
(
save_dir
)
evaluated
=
read_evaluated_file
(
evaluated_file
)
...
...
@@ -31,7 +31,7 @@ def save_n_best_models(train_dir, save_dir, evaluated_file,
x
=
x
[
1
]
ac
=
x
.
get
(
'
accuracy
'
)
or
0
lo
=
x
.
get
(
'
loss
'
)
or
0
if
sort_by
_
accuracy
:
if
sort_by
==
'
accuracy
'
:
return
(
ac
*
-
1
,
lo
)
else
:
return
(
lo
,
ac
*
-
1
)
...
...
@@ -149,11 +149,11 @@ def append_evaluated_file(path, evaluations):
help
=
'
If more than 0, will keep the best N models in the evaluation folder
'
)
@click.option
(
'
--sort-by
-accuracy
'
,
'
--sort-by
'
,
cls
=
ResourceOption
,
default
=
False
,
default
=
"
loss
"
,
show_default
=
True
,
help
=
'
If given, the N best models will be chosen based on accuracy instead of los
s.
'
)
help
=
'
The metric for sorting the N best model
s.
'
)
@click.option
(
'
--max-wait-intervals
'
,
cls
=
ResourceOption
,
...
...
@@ -163,7 +163,7 @@ def append_evaluated_file(path, evaluations):
help
=
'
If given, the maximum number of intervals waiting for new training checkpoint.
'
)
@verbosity_option
(
cls
=
ResourceOption
)
def
eval
(
estimator
,
eval_input_fn
,
hooks
,
run_once
,
eval_interval_secs
,
name
,
keep_n_best_models
,
sort_by
_accuracy
,
max_wait_intervals
,
**
kwargs
):
keep_n_best_models
,
sort_by
,
max_wait_intervals
,
**
kwargs
):
"""
Evaluates networks using Tensorflow estimators.
"""
log_parameters
(
logger
)
...
...
@@ -192,7 +192,7 @@ def eval(estimator, eval_input_fn, hooks, run_once, eval_interval_secs, name,
# Save the best N models into the eval directory
save_n_best_models
(
estimator
.
model_dir
,
eval_dir
,
evaluated_file
,
keep_n_best_models
,
sort_by
_accuracy
)
keep_n_best_models
,
sort_by
)
ckpt
=
tf
.
train
.
get_checkpoint_state
(
estimator
.
model_dir
)
if
(
not
ckpt
)
or
(
not
ckpt
.
model_checkpoint_path
):
...
...
@@ -229,7 +229,7 @@ def eval(estimator, eval_input_fn, hooks, run_once, eval_interval_secs, name,
# Save the best N models into the eval directory
save_n_best_models
(
estimator
.
model_dir
,
eval_dir
,
evaluated_file
,
keep_n_best_models
,
sort_by
_accuracy
)
keep_n_best_models
,
sort_by
)
if
run_once
:
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment