Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mednet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
medai
software
mednet
Commits
c7068292
Commit
c7068292
authored
2 years ago
by
ogueler@idiap.ch
Browse files
Options
Downloads
Patches
Plain Diff
removed strict parameter for checkpointing
parent
0209ebe1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Checkpointing cleanup
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ptbench/scripts/predict.py
+1
-1
1 addition, 1 deletion
src/ptbench/scripts/predict.py
src/ptbench/utils/checkpointer.py
+6
-10
6 additions, 10 deletions
src/ptbench/utils/checkpointer.py
with
7 additions
and
11 deletions
src/ptbench/scripts/predict.py
+
1
−
1
View file @
c7068292
...
...
@@ -131,7 +131,7 @@ def predict(
weight_fullpath
=
os
.
path
.
abspath
(
weight
)
checkpointer
=
Checkpointer
(
model
)
checkpointer
.
load
(
weight_fullpath
,
strict
=
False
)
checkpointer
.
load
(
weight_fullpath
)
# Logistic regressor weights
if
model
.
name
==
"
logistic_regression
"
:
...
...
This diff is collapsed.
Click to expand it.
src/ptbench/utils/checkpointer.py
+
6
−
10
View file @
c7068292
...
...
@@ -51,7 +51,7 @@ class Checkpointer:
with
open
(
self
.
_last_checkpoint_filename
,
"
w
"
)
as
f
:
f
.
write
(
name
)
def
load
(
self
,
f
=
None
,
strict
=
True
):
def
load
(
self
,
f
=
None
):
"""
Loads model, optimizer and scheduler from file.
Parameters
...
...
@@ -62,9 +62,6 @@ class Checkpointer:
contains the checkpoint data to load into the model, and optionally
into the optimizer and the scheduler. If not specified, loads data
from current path.
partial : :py:class:`bool`, Optional
If True, loading is not strict and only the model is loaded
"""
if
f
is
None
:
f
=
self
.
last_checkpoint
()
...
...
@@ -79,13 +76,12 @@ class Checkpointer:
checkpoint
=
torch
.
load
(
f
,
map_location
=
torch
.
device
(
"
cpu
"
))
# converts model entry to model parameters
self
.
model
.
load_state_dict
(
checkpoint
.
pop
(
"
model
"
)
,
strict
=
strict
)
self
.
model
.
load_state_dict
(
checkpoint
.
pop
(
"
model
"
))
if
strict
:
if
self
.
optimizer
is
not
None
:
self
.
optimizer
.
load_state_dict
(
checkpoint
.
pop
(
"
optimizer
"
))
if
self
.
scheduler
is
not
None
:
self
.
scheduler
.
load_state_dict
(
checkpoint
.
pop
(
"
scheduler
"
))
if
self
.
optimizer
is
not
None
:
self
.
optimizer
.
load_state_dict
(
checkpoint
.
pop
(
"
optimizer
"
))
if
self
.
scheduler
is
not
None
:
self
.
scheduler
.
load_state_dict
(
checkpoint
.
pop
(
"
scheduler
"
))
return
checkpoint
...
...
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