Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
20
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
90c6fbee
Commit
90c6fbee
authored
5 years ago
by
Mateusz Klimaszewski
Browse files
Options
Downloads
Patches
Plain Diff
Add logging metrics to console.
parent
2f459607
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
combo/training/tensorboard_writer.py
+32
-6
32 additions, 6 deletions
combo/training/tensorboard_writer.py
with
32 additions
and
6 deletions
combo/training/tensorboard_writer.py
+
32
−
6
View file @
90c6fbee
import
logging
from
typing
import
Dict
,
Optional
,
List
import
torch
...
...
@@ -5,6 +6,8 @@ from allennlp import models, common
from
allennlp.data
import
dataloader
from
allennlp.training
import
optimizers
logger
=
logging
.
getLogger
(
__name__
)
class
NullTensorboardWriter
(
common
.
FromParams
):
...
...
@@ -50,13 +53,36 @@ class NullTensorboardWriter(common.FromParams):
pass
def
log_metrics
(
self
,
train_metrics
:
dict
,
val_metrics
:
dict
=
None
,
epoch
:
int
=
None
,
log_to_console
:
bool
=
False
,
self
,
train_metrics
:
dict
,
val_metrics
:
dict
=
None
,
epoch
:
int
=
None
,
log_to_console
:
bool
=
False
,
)
->
None
:
pass
metric_names
=
set
(
train_metrics
.
keys
())
if
val_metrics
is
not
None
:
metric_names
.
update
(
val_metrics
.
keys
())
val_metrics
=
val_metrics
or
{}
if
log_to_console
:
dual_message_template
=
"
%s | %8.3f | %8.3f
"
no_val_message_template
=
"
%s | %8.3f | %8s
"
no_train_message_template
=
"
%s | %8s | %8.3f
"
header_template
=
"
%s | %-10s
"
name_length
=
max
(
len
(
x
)
for
x
in
metric_names
)
logger
.
info
(
header_template
,
"
Training
"
.
rjust
(
name_length
+
13
),
"
Validation
"
)
for
name
in
metric_names
:
train_metric
=
train_metrics
.
get
(
name
)
val_metric
=
val_metrics
.
get
(
name
)
if
val_metric
is
not
None
and
train_metric
is
not
None
:
logger
.
info
(
dual_message_template
,
name
.
ljust
(
name_length
),
train_metric
,
val_metric
)
elif
val_metric
is
not
None
:
logger
.
info
(
no_train_message_template
,
name
.
ljust
(
name_length
),
"
N/A
"
,
val_metric
)
elif
train_metric
is
not
None
:
logger
.
info
(
no_val_message_template
,
name
.
ljust
(
name_length
),
train_metric
,
"
N/A
"
)
def
enable_activation_logging
(
self
,
model
:
models
.
Model
)
->
None
:
pass
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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