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
1b94de2d
Commit
1b94de2d
authored
3 years ago
by
Caroline DE POURTALES
Browse files
Options
Downloads
Patches
Plain Diff
correction print
parent
7a10e2a9
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
Configuration/config.ini
+3
-4
3 additions, 4 deletions
Configuration/config.ini
Linker/Linker.py
+12
-12
12 additions, 12 deletions
Linker/Linker.py
train.py
+1
-1
1 addition, 1 deletion
train.py
with
16 additions
and
17 deletions
Configuration/config.ini
+
3
−
4
View file @
1b94de2d
...
@@ -12,15 +12,14 @@ max_atoms_in_one_type=250
...
@@ -12,15 +12,14 @@ max_atoms_in_one_type=250
dim_encoder
=
768
dim_encoder
=
768
[MODEL_DECODER]
[MODEL_DECODER]
dim_decoder
=
16
dim_decoder
=
32
num_rnn_layers
=
1
dropout
=
0.1
dropout
=
0.1
teacher_forcing
=
0.05
teacher_forcing
=
0.05
[MODEL_LINKER]
[MODEL_LINKER]
nhead
=
4
nhead
=
4
dim_feedforward
=
246
dim_feedforward
=
246
dim_embedding_atoms
=
16
dim_embedding_atoms
=
32
dim_polarity_transfo
=
128
dim_polarity_transfo
=
128
layer_norm_eps
=
1e-5
layer_norm_eps
=
1e-5
dropout
=
0.1
dropout
=
0.1
...
@@ -29,6 +28,6 @@ sinkhorn_iters=3
...
@@ -29,6 +28,6 @@ sinkhorn_iters=3
[MODEL_TRAINING]
[MODEL_TRAINING]
device
=
cpu
device
=
cpu
batch_size
=
32
batch_size
=
32
epoch
=
2
0
epoch
=
2
5
seed_val
=
42
seed_val
=
42
learning_rate
=
0.005
learning_rate
=
0.005
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Linker/Linker.py
+
12
−
12
View file @
1b94de2d
...
@@ -189,10 +189,10 @@ class Linker(Module):
...
@@ -189,10 +189,10 @@ class Linker(Module):
checkpoint_dir
,
writer
=
output_create_dir
()
checkpoint_dir
,
writer
=
output_create_dir
()
for
epoch_i
in
range
(
epochs
):
for
epoch_i
in
range
(
epochs
):
epoch_acc
,
epoch_loss
=
self
.
train_epoch
(
training_dataloader
)
avg_train_loss
,
avg_accuracy_train
=
self
.
train_epoch
(
training_dataloader
)
print
(
"
Average Loss on train dataset :
"
,
epoch
_loss
)
print
(
"
Average Loss on train dataset :
"
,
avg_train
_loss
)
print
(
"
Average Accuracy on train dataset :
"
,
epoch_acc
)
print
(
"
Average Accuracy on train dataset :
"
,
avg_accuracy_train
)
if
checkpoint
:
if
checkpoint
:
self
.
__checkpoint_save
(
self
.
__checkpoint_save
(
...
@@ -200,20 +200,20 @@ class Linker(Module):
...
@@ -200,20 +200,20 @@ class Linker(Module):
if
validation_rate
>
0.0
:
if
validation_rate
>
0.0
:
with
torch
.
no_grad
():
with
torch
.
no_grad
():
accuracy_test
,
average_test_loss
=
self
.
eval_epoch
(
validation_dataloader
,
self
.
cross_entropy_loss
)
loss_test
,
accuracy_test
=
self
.
eval_epoch
(
validation_dataloader
,
self
.
cross_entropy_loss
)
print
(
"
Average Loss on test dataset :
"
,
average_test_loss
)
print
(
"
Average Loss on test dataset :
"
,
loss_test
)
print
(
"
Average Accuracy on test dataset :
"
,
accuracy_test
)
print
(
"
Average Accuracy on test dataset :
"
,
accuracy_test
)
if
tensorboard
:
if
tensorboard
:
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
'
Train
'
:
epoch_acc
},
epoch_i
)
'
Train
'
:
avg_accuracy_train
},
epoch_i
)
writer
.
add_scalars
(
f
'
Loss
'
,
{
writer
.
add_scalars
(
f
'
Loss
'
,
{
'
Train
'
:
epoch
_loss
},
epoch_i
)
'
Train
'
:
avg_train
_loss
},
epoch_i
)
if
validation_rate
>
0.0
:
if
validation_rate
>
0.0
:
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
'
Validation
'
:
accuracy_test
},
epoch_i
)
'
Validation
'
:
accuracy_test
},
epoch_i
)
writer
.
add_scalars
(
f
'
Loss
'
,
{
writer
.
add_scalars
(
f
'
Loss
'
,
{
'
Validation
'
:
average_test_loss
},
epoch_i
)
'
Validation
'
:
loss_test
},
epoch_i
)
print
(
'
\n
'
)
print
(
'
\n
'
)
...
@@ -336,7 +336,7 @@ class Linker(Module):
...
@@ -336,7 +336,7 @@ class Linker(Module):
accuracy
=
mesure_accuracy
(
batch_true_links
,
axiom_links_pred
)
accuracy
=
mesure_accuracy
(
batch_true_links
,
axiom_links_pred
)
loss
=
cross_entropy_loss
(
logits_axiom_links_pred
,
batch_true_links
)
loss
=
cross_entropy_loss
(
logits_axiom_links_pred
,
batch_true_links
)
return
accuracy
,
loss
return
loss
,
accuracy
def
eval_epoch
(
self
,
dataloader
,
cross_entropy_loss
):
def
eval_epoch
(
self
,
dataloader
,
cross_entropy_loss
):
r
"""
Average the evaluation of all the batch.
r
"""
Average the evaluation of all the batch.
...
@@ -347,11 +347,11 @@ class Linker(Module):
...
@@ -347,11 +347,11 @@ class Linker(Module):
accuracy_average
=
0
accuracy_average
=
0
loss_average
=
0
loss_average
=
0
for
step
,
batch
in
enumerate
(
dataloader
):
for
step
,
batch
in
enumerate
(
dataloader
):
accuracy
,
loss
=
self
.
eval_batch
(
batch
,
cross_entropy_loss
)
loss
,
accuracy
=
self
.
eval_batch
(
batch
,
cross_entropy_loss
)
accuracy_average
+=
accuracy
accuracy_average
+=
accuracy
loss_average
+=
loss
loss_average
+=
float
(
loss
)
return
accuracy
_average
/
len
(
dataloader
),
loss
_average
/
len
(
dataloader
)
return
loss
_average
/
len
(
dataloader
),
accuracy
_average
/
len
(
dataloader
)
def
load_weights
(
self
,
model_file
):
def
load_weights
(
self
,
model_file
):
print
(
"
#
"
*
15
)
print
(
"
#
"
*
15
)
...
...
This diff is collapsed.
Click to expand it.
train.py
+
1
−
1
View file @
1b94de2d
...
@@ -6,7 +6,7 @@ from utils import read_csv_pgbar
...
@@ -6,7 +6,7 @@ from utils import read_csv_pgbar
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
empty_cache
()
batch_size
=
int
(
Configuration
.
modelTrainingConfig
[
'
batch_size
'
])
batch_size
=
int
(
Configuration
.
modelTrainingConfig
[
'
batch_size
'
])
nb_sentences
=
batch_size
*
20
0
nb_sentences
=
batch_size
*
20
epochs
=
int
(
Configuration
.
modelTrainingConfig
[
'
epoch
'
])
epochs
=
int
(
Configuration
.
modelTrainingConfig
[
'
epoch
'
])
file_path_axiom_links
=
'
Datasets/goldANDsilver_dataset_links.csv
'
file_path_axiom_links
=
'
Datasets/goldANDsilver_dataset_links.csv
'
...
...
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