Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JoeyNMT Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
Simon Will
JoeyNMT Server
Commits
6f760230
Commit
6f760230
authored
4 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Don’t reset scheduler and optimizer if loading a checkpoint from online learning
parent
9f0349fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
joeynmt_server/joey_model.py
+25
-4
25 additions, 4 deletions
joeynmt_server/joey_model.py
with
25 additions
and
4 deletions
joeynmt_server/joey_model.py
+
25
−
4
View file @
6f760230
...
...
@@ -37,6 +37,29 @@ def make_config_absolute(config, root):
return
config
def
get_saver
(
ckpt
):
saver
=
None
base_without_ext
,
_
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
ckpt
))
saver_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
ckpt
),
'
{}.saver
'
.
format
(
base_without_ext
))
if
os
.
path
.
isfile
(
saver_path
):
with
open
(
saver_path
)
as
f
:
saver
=
f
.
read
()
return
saver
def
set_reset_config
(
training_config
,
ckpt
):
saver
=
get_saver
(
ckpt
)
if
saver
==
'
nlmaps
'
:
training_config
[
'
reset_best_ckpt
'
]
=
False
training_config
[
'
reset_scheduler
'
]
=
False
training_config
[
'
reset_optimizer
'
]
=
False
else
:
training_config
[
'
reset_best_ckpt
'
]
=
False
training_config
[
'
reset_scheduler
'
]
=
True
training_config
[
'
reset_optimizer
'
]
=
True
class
JoeyModel
:
def
__init__
(
self
,
config
,
model
,
train_manager
,
src_field
,
trg_field
,
...
...
@@ -106,9 +129,7 @@ class JoeyModel:
ckpt
=
get_latest_checkpoint
(
model_dir
)
ckpt_ctime
=
os
.
path
.
getctime
(
ckpt
)
config
[
'
training
'
][
'
load_model
'
]
=
ckpt
config
[
'
training
'
][
'
reset_best_ckpt
'
]
=
False
config
[
'
training
'
][
'
reset_scheduler
'
]
=
True
config
[
'
training
'
][
'
reset_optimizer
'
]
=
True
set_reset_config
(
config
[
'
training
'
],
ckpt
)
train_manager
=
TrainManager
(
model
=
model
,
config
=
config
)
#model_checkpoint = load_checkpoint(ckpt, use_cuda=test_args['use_cuda'])
...
...
@@ -234,7 +255,7 @@ class JoeyModel:
batch_callback
(
batch
)
logging
.
info
(
'
Finished training after {} batches
'
.
format
(
i
+
1
))
trainer
.
_save_checkpoint
()
trainer
.
_save_checkpoint
(
saver
=
'
nlmaps
'
)
if
dev_set
:
dev_results
=
self
.
validate
(
dev_set
)
...
...
This diff is collapsed.
Click to expand it.
Simon Will
@will
mentioned in commit
40e914d9
·
4 years ago
mentioned in commit
40e914d9
mentioned in commit 40e914d976c2d7f80f4e68ca6e8c3e9c10985076
Toggle commit list
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