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
22a63f44
Commit
22a63f44
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Confusion matrix is now saved to file
parent
cafc978b
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pytorch/eval.py
+6
-0
6 additions, 0 deletions
pytorch/eval.py
with
6 additions
and
0 deletions
pytorch/eval.py
+
6
−
0
View file @
22a63f44
...
...
@@ -30,6 +30,7 @@ def predict(model, dataloader, optimizer, accuracy, state_file=None):
nbatches
=
int
(
len
(
dataloader
.
dataset
)
/
dataloader
.
batch_size
)
# iterate over the validation/test set
accuracies
=
[]
for
batch
,
(
inputs
,
labels
)
in
enumerate
(
dataloader
):
# send the data to the gpu if available
...
...
@@ -45,6 +46,7 @@ def predict(model, dataloader, optimizer, accuracy, state_file=None):
# calculate accuracy
acc
=
accuracy
(
pred
,
labels
)
accuracies
.
append
(
acc
)
# print progress
print
(
'
Batch: {:d}/{:d}, Accuracy: {:.2f}
'
.
format
(
batch
,
...
...
@@ -54,6 +56,10 @@ def predict(model, dataloader, optimizer, accuracy, state_file=None):
for
ytrue
,
ypred
in
zip
(
labels
.
view
(
-
1
),
pred
.
view
(
-
1
)):
cm
[
ytrue
.
long
(),
ypred
.
long
()]
+=
1
# save confusion matrix and accuracies to file
torch
.
save
({
'
cm
'
:
cm
,
'
accuracy
'
:
accuracies
},
state
.
split
(
'
.pt
'
)[
0
]
+
'
_cm.pt
'
)
return
cm
...
...
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