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
eff2f26e
Commit
eff2f26e
authored
3 years ago
by
Caroline DE POURTALES
Browse files
Options
Downloads
Patches
Plain Diff
update utils
parent
140ce64e
No related branches found
No related tags found
3 merge requests
!6
Linker with transformer
,
!5
Linker with transformer
,
!2
Change preprocess
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Configuration/config.ini
+1
-1
1 addition, 1 deletion
Configuration/config.ini
Linker/Linker.py
+6
-4
6 additions, 4 deletions
Linker/Linker.py
with
7 additions
and
5 deletions
Configuration/config.ini
+
1
−
1
View file @
eff2f26e
...
...
@@ -26,7 +26,7 @@ dropout=0.1
sinkhorn_iters
=
3
[MODEL_TRAINING]
batch_size
=
16
batch_size
=
32
epoch
=
30
seed_val
=
42
learning_rate
=
2e-4
This diff is collapsed.
Click to expand it.
Linker/Linker.py
+
6
−
4
View file @
eff2f26e
...
...
@@ -257,7 +257,8 @@ class Linker(Module):
logits
,
sentences_embedding
=
self
.
Supertagger
.
forward
(
batch_sentences_tokens
,
batch_sentences_mask
)
# Run the kinker on the categories predictions
logits_predictions
=
self
(
batch_atoms
,
batch_pos_idx
,
batch_neg_idx
,
sentences_embedding
,
batch_sentences_mask
)
logits_predictions
=
self
(
batch_atoms
,
batch_pos_idx
,
batch_neg_idx
,
sentences_embedding
,
batch_sentences_mask
)
linker_loss
=
self
.
cross_entropy_loss
(
logits_predictions
,
batch_true_links
)
# Perform a backward pass to calculate the gradients.
...
...
@@ -366,9 +367,10 @@ class Linker(Module):
:param positional_ids:
A List of batch_size elements, each being a List of num_atoms LongTensors.
Each LongTensor in positional_ids[b][a] indexes the location of atoms of type a in sentence b.
:param
devic
e:
:param
atom_typ
e:
:return:
"""
return
[[
bsd_tensor
.
select
(
0
,
index
=
i
).
index_select
(
0
,
index
=
atom
.
to
(
self
.
device
))
for
atom
in
sentence
]
for
i
,
sentence
in
enumerate
(
positional_ids
[
atom_map_redux
[
atom_type
]])]
\ No newline at end of file
return
torch
.
stack
([
torch
.
stack
([
bsd_tensor
.
select
(
0
,
index
=
i
).
select
(
0
,
index
=
int
(
atom
))
if
atom
!=
-
1
else
torch
.
zeros
(
self
.
dim_embedding_atoms
)
for
atom
in
sentence
])
for
i
,
sentence
in
enumerate
(
positional_ids
[:,
atom_map_redux
[
atom_type
],
:])])
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