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
afda23a9
Commit
afda23a9
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Save losses and accuracy after each epoch
parent
22a63f44
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pytorch/train.py
+4
-4
4 additions, 4 deletions
pytorch/train.py
with
4 additions
and
4 deletions
pytorch/train.py
+
4
−
4
View file @
afda23a9
...
...
@@ -80,9 +80,9 @@ def train(model, dataloader, loss_function, optimizer, accuracy, state_file,
# save model state to file
state
=
model
.
save
(
optimizer
,
state_file
)
# save losses and accuracy to file
torch
.
save
({
'
loss
'
:
losses
,
'
accuracy
'
:
accuracies
},
state
.
split
(
'
.pt
'
)[
0
]
+
'
_loss.pt
'
)
# save losses and accuracy to file
torch
.
save
({
'
loss
'
:
losses
,
'
accuracy
'
:
accuracies
},
state
.
split
(
'
.pt
'
)[
0
]
+
'
_loss.pt
'
)
return
losses
,
accuracies
...
...
@@ -103,7 +103,7 @@ def train_test_split(ds, ratio, seed=0):
test_len
=
ds_len
(
ds
,
1
-
ratio
)
# split dataset into training and test set
# (
tt
ratio * 100) % will be used for training and validation
# (ratio * 100) % will be used for training and validation
train_ds
,
test_ds
=
random_split
(
ds
,
(
train_len
,
test_len
))
return
train_ds
,
test_ds
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