Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NN Projekt SS22
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
kreuzer
NN Projekt SS22
Commits
38fe2086
Commit
38fe2086
authored
2 years ago
by
wu
Browse files
Options
Downloads
Patches
Plain Diff
compute sent vecs mit best model
parent
ca546013
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/ActorOnly+CEL/main_ActorOnly.py
+7
-8
7 additions, 8 deletions
scripts/ActorOnly+CEL/main_ActorOnly.py
structures.py
+4
-3
4 additions, 3 deletions
structures.py
with
11 additions
and
11 deletions
scripts/ActorOnly+CEL/main_ActorOnly.py
+
7
−
8
View file @
38fe2086
...
...
@@ -54,6 +54,13 @@ for epoch in range(epochs):
# (over)write best model in file, and for Critic: save model_actor_only
torch
.
save
(
m
.
state_dict
(),
'
model_actor_only_wts.pth
'
)
# load best model and compute sent_vecs anew
best_m
=
ActorOnlySummarisationModel
()
best_m
.
load_state_dict
(
best_model_wts
)
train_data
.
compute_sent_vecs
(
best_m
,
'
workspace/students/kreuzer/new_train
'
)
#
val_data
.
compute_sent_vecs
(
best_m
,
'
workspace/students/kreuzer/new_val
'
)
test_data
.
compute_sent_vecs
(
best_m
,
'
workspace/students/kreuzer/new_test
'
)
time_elapsed
=
time
.
time
()
-
since
print
(
'
Training + validation running already {:.0f}m {:.0f}s
'
.
format
(
time_elapsed
//
60
,
time_elapsed
%
60
))
print
(
'
Best val rouge so far: {:4f}
'
.
format
(
best_rouge
))
...
...
@@ -72,14 +79,6 @@ print('Best val rouge: {:4f}'.format(best_rouge))
# load best model weights
m
.
load_state_dict
(
best_model_wts
)
# set sent_vecs
train_data
.
compute_sent_vecs
(
m
,
'
workspace/students/kreuzer/new_train
'
)
#
val_data
.
compute_sent_vecs
(
m
,
'
workspace/students/kreuzer/new_val
'
)
test_data
.
compute_sent_vecs
(
m
,
'
workspace/students/kreuzer/new_test
'
)
# testing
since
=
time
.
time
()
...
...
This diff is collapsed.
Click to expand it.
structures.py
+
4
−
3
View file @
38fe2086
...
...
@@ -92,7 +92,7 @@ class PreprocessedDataSet:
self
.
path
=
path
self
.
path
.
mkdir
()
self
.
length
=
len
(
dataset
)
for
i
,
element
in
enumerate
(
dataset
):
...
...
@@ -132,8 +132,9 @@ class PreprocessedDataSet:
def
compute_sent_vecs
(
self
,
model
,
path
):
path
=
pathlib
.
Path
(
path
)
path
.
mkdir
()
# writes in file, allows overwriting in main_ActorOnly
pathlib
.
Path
(
path
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
for
i
in
range
(
self
.
length
):
dp
=
self
.
__getitem__
(
i
)
dp
.
compute_sent_vecs
(
model
)
...
...
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