Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DeepGrail Tagger
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 Tagger
Commits
23e27a4c
Commit
23e27a4c
authored
3 years ago
by
Julien Rabault
Browse files
Options
Downloads
Patches
Plain Diff
remove argmax output
parent
36720c72
No related branches found
No related tags found
1 merge request
!1
Draft: Master
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SuperTagger/SuperTagger.py
+1
-1
1 addition, 1 deletion
SuperTagger/SuperTagger.py
SuperTagger/Utils/Tagging_bert_model.py
+1
-1
1 addition, 1 deletion
SuperTagger/Utils/Tagging_bert_model.py
SuperTagger/Utils/utils.py
+13
-0
13 additions, 0 deletions
SuperTagger/Utils/utils.py
with
15 additions
and
2 deletions
SuperTagger/SuperTagger.py
+
1
−
1
View file @
23e27a4c
...
@@ -161,7 +161,7 @@ class SuperTagger:
...
@@ -161,7 +161,7 @@ class SuperTagger:
preds
,
hidden
=
self
.
model
.
predict
((
sents_tokenized_t
,
sents_mask_t
))
preds
,
hidden
=
self
.
model
.
predict
((
sents_tokenized_t
,
sents_mask_t
))
return
preds
,
self
.
tags_tokenizer
.
convert_ids_to_tags
(
preds
.
detach
()),
hidden
return
preds
,
self
.
tags_tokenizer
.
convert_ids_to_tags
(
torch
.
argmax
(
preds
,
dim
=
2
)
.
detach
()),
hidden
def
train
(
self
,
sentences
:
list
[
str
],
tags
:
list
[
list
[
str
]],
validation_rate
=
0.1
,
epochs
=
20
,
batch_size
=
32
,
def
train
(
self
,
sentences
:
list
[
str
],
tags
:
list
[
list
[
str
]],
validation_rate
=
0.1
,
epochs
=
20
,
batch_size
=
32
,
tensorboard
=
False
,
tensorboard
=
False
,
...
...
This diff is collapsed.
Click to expand it.
SuperTagger/Utils/Tagging_bert_model.py
+
1
−
1
View file @
23e27a4c
...
@@ -38,4 +38,4 @@ class Tagging_bert_model(Module):
...
@@ -38,4 +38,4 @@ class Tagging_bert_model(Module):
output
=
self
.
bert
(
output
=
self
.
bert
(
input_ids
=
b_input_ids
,
attention_mask
=
b_input_mask
)
input_ids
=
b_input_ids
,
attention_mask
=
b_input_mask
)
return
torch
.
argmax
(
output
[
0
],
dim
=
2
),
output
[
1
][
0
]
return
output
[
0
],
output
[
1
][
0
]
This diff is collapsed.
Click to expand it.
SuperTagger/Utils/utils.py
+
13
−
0
View file @
23e27a4c
...
@@ -27,5 +27,18 @@ def load_obj(name):
...
@@ -27,5 +27,18 @@ def load_obj(name):
import
pickle
import
pickle
return
pickle
.
load
(
f
)
return
pickle
.
load
(
f
)
def
categorical_accuracy_str
(
preds
:
list
[
list
[
float
]],
truth
:
list
[
list
[
float
]])
->
float
:
nb_label
=
0
good_label
=
0
for
i
in
range
(
len
(
truth
)):
sublist_truth
=
truth
[
i
]
sublist_preds
=
preds
[
i
]
for
j
in
range
(
min
(
len
(
sublist_truth
),
len
(
sublist_preds
))):
if
str
(
sublist_truth
[
j
])
==
str
(
sublist_preds
[
j
]):
good_label
+=
1
nb_label
+=
1
return
good_label
/
nb_label
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