Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
3pia
CMS Analyses
Tools
Commits
283c73f2
Commit
283c73f2
authored
3 years ago
by
Dennis Noll
Browse files
Options
Downloads
Patches
Plain Diff
[tools] comet: black
parent
d2340589
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comet.py
+40
-25
40 additions, 25 deletions
comet.py
with
40 additions
and
25 deletions
comet.py
+
40
−
25
View file @
283c73f2
import
tensorflow
as
tf
from
tools.keras
import
PlottingCallback
class
MulticlassificationConfusionMatrix
(
tf
.
keras
.
callbacks
.
Callback
):
def
__init__
(
self
,
comet_experiment
,
x
=
None
,
y
=
None
,
sample_weights
=
None
,
batch_size
=
None
,
labels
=
None
,
freq
=
100
,
verbose
=
0
):
def
__init__
(
self
,
comet_experiment
,
x
=
None
,
y
=
None
,
sample_weights
=
None
,
batch_size
=
None
,
labels
=
None
,
freq
=
100
,
verbose
=
0
,
):
self
.
comet_experiment
=
comet_experiment
self
.
data_x
=
x
self
.
data_label
=
y
self
.
data_weights
=
sample_weights
self
.
data_x
=
x
self
.
data_label
=
y
self
.
data_weights
=
sample_weights
self
.
batch_size
=
batch_size
self
.
freq
=
freq
self
.
labels
=
labels
self
.
verbose
=
verbose
def
on_train_begin
(
self
,
logs
=
None
):
if
self
.
verbose
:
print
(
"
Logging confusion matrix to comet experiment
"
)
pred
=
self
.
model
.
predict
(
x
=
self
.
data_x
,
batch_size
=
self
.
batch_size
)
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion Start
"
,
epoch
=
0
,
file_name
=
"
confusion-matrix-0.json
"
)
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion Start
"
,
epoch
=
0
,
file_name
=
"
confusion-matrix-0.json
"
,
)
def
on_epoch_end
(
self
,
epoch
,
logs
=
None
):
if
epoch
%
self
.
freq
==
0
and
epoch
!=
0
:
if
epoch
%
self
.
freq
==
0
and
epoch
!=
0
:
if
self
.
verbose
:
print
(
"
Logging confusion matrix to comet experiment
"
)
pred
=
self
.
model
.
predict
(
x
=
self
.
data_x
,
batch_size
=
self
.
batch_size
)
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion Epoch {}
"
.
format
(
epoch
),
epoch
=
epoch
,
file_name
=
"
confusion-matrix-{}.json
"
.
format
(
epoch
))
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion Epoch {}
"
.
format
(
epoch
),
epoch
=
epoch
,
file_name
=
"
confusion-matrix-{}.json
"
.
format
(
epoch
),
)
def
on_train_end
(
self
,
logs
=
None
):
if
self
.
verbose
:
print
(
"
Logging confusion matrix to comet experiment
"
)
pred
=
self
.
model
.
predict
(
x
=
self
.
data_x
,
batch_size
=
self
.
batch_size
)
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion End
"
,
epoch
=-
1
,
file_name
=
"
confusion-matrix-end.json
"
)
self
.
comet_experiment
.
log_confusion_matrix
(
y_true
=
self
.
data_label
,
y_predicted
=
pred
,
labels
=
self
.
labels
,
title
=
"
Confusion End
"
,
epoch
=-
1
,
file_name
=
"
confusion-matrix-end.json
"
,
)
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