Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DeepGrail Linker
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
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
PNRIA
Global Helper
DeepGrail Linker
Commits
77ac0b86
Commit
77ac0b86
authored
3 years ago
by
Caroline DE POURTALES
Browse files
Options
Downloads
Patches
Plain Diff
brouillon main predict
parent
8d109c5a
No related branches found
No related tags found
2 merge requests
!6
Linker with transformer
,
!5
Linker with transformer
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Linker/Linker.py
+3
-0
3 additions, 0 deletions
Linker/Linker.py
SuperTagger/__init__.py
+0
-0
0 additions, 0 deletions
SuperTagger/__init__.py
main.py
+9
-7
9 additions, 7 deletions
main.py
with
12 additions
and
7 deletions
Linker/Linker.py
+
3
−
0
View file @
77ac0b86
...
@@ -192,6 +192,7 @@ class Linker(Module):
...
@@ -192,6 +192,7 @@ class Linker(Module):
self
.
scheduler
.
step
()
self
.
scheduler
.
step
()
avg_train_loss
=
epoch_loss
/
len
(
training_dataloader
)
avg_train_loss
=
epoch_loss
/
len
(
training_dataloader
)
print
(
"
Average Loss on train dataset :
"
,
avg_train_loss
)
if
checkpoint
:
if
checkpoint
:
checkpoint_dir
=
os
.
path
.
join
(
"
Output
"
,
'
Tranning_
'
+
datetime
.
today
().
strftime
(
'
%d-%m_%H-%M
'
))
checkpoint_dir
=
os
.
path
.
join
(
"
Output
"
,
'
Tranning_
'
+
datetime
.
today
().
strftime
(
'
%d-%m_%H-%M
'
))
...
@@ -200,6 +201,8 @@ class Linker(Module):
...
@@ -200,6 +201,8 @@ class Linker(Module):
if
validate
:
if
validate
:
with
torch
.
no_grad
():
with
torch
.
no_grad
():
accuracy
,
average_test_loss
=
self
.
eval_epoch
(
validation_dataloader
,
self
.
cross_entropy_loss
)
accuracy
,
average_test_loss
=
self
.
eval_epoch
(
validation_dataloader
,
self
.
cross_entropy_loss
)
print
(
"
Average Loss on test dataset :
"
,
average_test_loss
)
print
(
"
Average Accuracy on test dataset :
"
,
accuracy
)
return
accuracy
,
avg_train_loss
return
accuracy
,
avg_train_loss
...
...
This diff is collapsed.
Click to expand it.
SuperTagger/__init__.py
deleted
100644 → 0
+
0
−
0
View file @
8d109c5a
This diff is collapsed.
Click to expand it.
main.py
+
9
−
7
View file @
77ac0b86
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
import
torch
from
Configuration
import
Configuration
from
Configuration
import
Configuration
from
Linker.Linker
import
Linker
from
Linker.Linker
import
Linker
from
Supertagger.SuperTagger.SuperTagger
import
SuperTagger
from
Supertagger.SuperTagger.SuperTagger
import
SuperTagger
...
@@ -7,15 +7,17 @@ from Supertagger.SuperTagger.SuperTagger import SuperTagger
...
@@ -7,15 +7,17 @@ from Supertagger.SuperTagger.SuperTagger import SuperTagger
max_atoms_in_sentence
=
int
(
Configuration
.
datasetConfig
[
'
max_atoms_in_sentence
'
])
max_atoms_in_sentence
=
int
(
Configuration
.
datasetConfig
[
'
max_atoms_in_sentence
'
])
# categories tagger
# categories tagger
tagger
=
SuperTagger
()
super
tagger
=
SuperTagger
()
tagger
.
load_weights
(
"
models/model_
check
.pt
"
)
super
tagger
.
load_weights
(
"
models/model_
supertagger
.pt
"
)
# axiom linker
# axiom linker
linker
=
Linker
()
linker
=
Linker
(
supertagger
)
linker
.
load_weights
(
"
models/linker.pt
"
)
linker
.
load_weights
(
"
models/linker.pt
"
)
# predict categories and links for this sentence
# predict categories and links for this sentence
sentence
=
[[]]
sentence
=
[
"
le chat est noir
"
]
categories
,
sentence_embedding
=
tagger
.
predict
(
sentence
)
sents_tokenized
,
sents_mask
=
supertagger
.
sent_tokenizer
.
fit_transform_tensors
(
sentence
)
logits
,
sentence_embedding
=
supertagger
.
foward
(
sents_tokenized
,
sents_mask
)
categories
=
torch
.
argmax
(
F
.
softmax
(
logits
,
dim
=
2
),
dim
=
2
)
axiom_links
=
linker
.
predict
(
categories
,
sentence_embedding
)
axiom_links
=
linker
.
predict
(
categories
,
sentence_embedding
,
sents_mask
)
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