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
d1c8b813
Commit
d1c8b813
authored
2 years ago
by
Caroline DE POURTALES
Browse files
Options
Downloads
Patches
Plain Diff
change padding handling
parent
a539008d
No related branches found
No related tags found
3 merge requests
!6
Linker with transformer
,
!5
Linker with transformer
,
!3
Working on padding
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Configuration/config.ini
+3
-3
3 additions, 3 deletions
Configuration/config.ini
Linker/DataParallelLinker.py
+64
-0
64 additions, 0 deletions
Linker/DataParallelLinker.py
with
67 additions
and
3 deletions
Configuration/config.ini
+
3
−
3
View file @
d1c8b813
...
...
@@ -4,7 +4,7 @@ transformers = 4.16.2
[DATASET_PARAMS]
symbols_vocab_size
=
26
atom_vocab_size
=
18
max_len_sentence
=
290
max_len_sentence
=
83
max_atoms_in_sentence
=
875
max_atoms_in_one_type
=
324
...
...
@@ -12,10 +12,10 @@ max_atoms_in_one_type=324
dim_encoder
=
768
[MODEL_LINKER]
nhead
=
8
nhead
=
16
dim_emb_atom
=
256
dim_feedforward_transformer
=
768
num_layers
=
2
num_layers
=
3
dim_cat_inter
=
512
dim_cat_out
=
256
dim_intermediate_FFN
=
128
...
...
This diff is collapsed.
Click to expand it.
Linker/DataParallelLinker.py
0 → 100644
+
64
−
0
View file @
d1c8b813
import
datetime
from
torch.nn
import
DataParallel
,
Module
from
Linker
import
*
class
DataParallelModel
(
Module
):
def
__init__
(
self
):
super
().
__init__
()
self
.
linker
=
DataParallel
(
Linker
(
"
models/flaubert_super_98_V2_50e.pt
"
))
def
forward
(
self
,
x
):
x
=
self
.
linker
(
x
)
return
x
def
train_linker
(
self
,
df_axiom_links
,
validation_rate
=
0.1
,
epochs
=
20
,
batch_size
=
32
,
checkpoint
=
True
,
tensorboard
=
False
):
r
"""
Args:
df_axiom_links : pandas dataFrame containing the atoms anoted with _i
validation_rate : float
epochs : int
batch_size : int
checkpoint : boolean
tensorboard : boolean
Returns:
Final accuracy and final loss
"""
training_dataloader
,
validation_dataloader
=
self
.
__preprocess_data
(
batch_size
,
df_axiom_links
,
validation_rate
)
if
checkpoint
or
tensorboard
:
checkpoint_dir
,
writer
=
output_create_dir
()
for
epoch_i
in
range
(
epochs
):
print
(
""
)
print
(
'
======== Epoch {:} / {:} ========
'
.
format
(
epoch_i
+
1
,
epochs
))
print
(
'
Training...
'
)
avg_train_loss
,
avg_accuracy_train
,
training_time
=
self
.
train_epoch
(
training_dataloader
)
print
(
""
)
print
(
f
'
Epoch:
{
epoch_i
+
1
:
02
}
| Epoch Time:
{
training_time
}
'
)
print
(
f
'
\t
Train Loss:
{
avg_train_loss
:
.
3
f
}
| Train Acc:
{
avg_accuracy_train
*
100
:
.
2
f
}
%
'
)
if
validation_rate
>
0.0
:
loss_test
,
accuracy_test
=
self
.
eval_epoch
(
validation_dataloader
)
print
(
f
'
\t
Val Loss:
{
loss_test
:
.
3
f
}
| Val Acc:
{
accuracy_test
*
100
:
.
2
f
}
%
'
)
if
checkpoint
:
self
.
__checkpoint_save
(
path
=
os
.
path
.
join
(
"
Output
"
,
'
linker
'
+
datetime
.
today
().
strftime
(
'
%d-%m_%H-%M
'
)
+
'
.pt
'
))
if
tensorboard
:
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
'
Train
'
:
avg_accuracy_train
},
epoch_i
)
writer
.
add_scalars
(
f
'
Loss
'
,
{
'
Train
'
:
avg_train_loss
},
epoch_i
)
if
validation_rate
>
0.0
:
writer
.
add_scalars
(
f
'
Accuracy
'
,
{
'
Validation
'
:
accuracy_test
},
epoch_i
)
writer
.
add_scalars
(
f
'
Loss
'
,
{
'
Validation
'
:
loss_test
},
epoch_i
)
print
(
'
\n
'
)
\ No newline at end of file
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