Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
earth_observation_public
PySegCNN
Commits
8199ac71
Commit
8199ac71
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented the sklearn implementation of the confusion matrix.
parent
4a56331e
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
pysegcnn/core/trainer.py
+3
-7
3 additions, 7 deletions
pysegcnn/core/trainer.py
with
3 additions
and
7 deletions
pysegcnn/core/trainer.py
+
3
−
7
View file @
8199ac71
...
...
@@ -35,6 +35,7 @@ import torch.nn as nn
import
torch.nn.functional
as
F
from
torch.utils.data
import
DataLoader
from
torch.optim
import
Optimizer
from
sklearn.metrics
import
confusion_matrix
# locals
from
pysegcnn.core.dataset
import
SupportedDatasets
...
...
@@ -2611,14 +2612,9 @@ class NetworkInference(BaseConfig):
# check whether to calculate confusion matrix
if
self
.
cm
:
# initialize confusion matrix
conf_mat
=
np
.
zeros
(
shape
=
2
*
(
len
(
self
.
src_ds
.
labels
),
))
# calculate confusion matrix
for
ytrue
,
ypred
in
zip
(
output
[
'
y
'
].
flatten
(),
output
[
'
y_pred
'
].
flatten
()):
# update confusion matrix entries
conf_mat
[
ytrue
.
long
(),
ypred
.
long
()]
+=
1
conf_mat
=
confusion_matrix
(
output
[
'
y
'
].
numpy
().
flatten
(),
output
[
'
y_pred
'
].
numpy
().
flatten
())
# add confusion matrix to model output
output
[
'
cm
'
]
=
conf_mat
...
...
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