Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaëtan Caillaut
hatespeech
Commits
35bd6c7f
Commit
35bd6c7f
authored
Jun 09, 2021
by
Gaëtan Caillaut
Browse files
eval_model peut recevoir des modèles huggingface
parent
6f34a7a8
Changes
1
Show whitespace changes
Inline
Side-by-side
evaluation.py
View file @
35bd6c7f
...
@@ -13,7 +13,11 @@ def eval_model(model, dataloader, device):
...
@@ -13,7 +13,11 @@ def eval_model(model, dataloader, device):
labels
=
labels
.
to
(
device
)
labels
=
labels
.
to
(
device
)
logits
=
model
(
x
,
attention_mask
)
logits
=
model
(
x
,
attention_mask
)
try
:
predicted
=
torch
.
argmax
(
logits
,
dim
=-
1
).
tolist
()
predicted
=
torch
.
argmax
(
logits
,
dim
=-
1
).
tolist
()
except
TypeError
:
# Si le modèle provient de huggingface
predicted
=
torch
.
argmax
(
logits
[
"logits"
],
dim
=-
1
).
tolist
()
for
pred
,
gold
in
zip
(
predicted
,
labels
.
tolist
()):
for
pred
,
gold
in
zip
(
predicted
,
labels
.
tolist
()):
if
gold
not
in
confusion
:
if
gold
not
in
confusion
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment