Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
c0281feb
Unverified
Commit
c0281feb
authored
Mar 03, 2022
by
davidleonfdez
Committed by
GitHub
Mar 03, 2022
Browse files
Fix #15898 (#15928)
parent
9251427c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
examples/pytorch/language-modeling/run_clm.py
examples/pytorch/language-modeling/run_clm.py
+4
-0
examples/pytorch/language-modeling/run_mlm.py
examples/pytorch/language-modeling/run_mlm.py
+4
-0
No files found.
examples/pytorch/language-modeling/run_clm.py
View file @
c0281feb
...
@@ -454,6 +454,10 @@ def main():
...
@@ -454,6 +454,10 @@ def main():
eval_dataset
=
eval_dataset
.
select
(
range
(
data_args
.
max_eval_samples
))
eval_dataset
=
eval_dataset
.
select
(
range
(
data_args
.
max_eval_samples
))
def
preprocess_logits_for_metrics
(
logits
,
labels
):
def
preprocess_logits_for_metrics
(
logits
,
labels
):
if
isinstance
(
logits
,
tuple
):
# Depending on the model and config, logits may contain extra tensors,
# like past_key_values, but logits always come first
logits
=
logits
[
0
]
return
logits
.
argmax
(
dim
=-
1
)
return
logits
.
argmax
(
dim
=-
1
)
metric
=
load_metric
(
"accuracy"
)
metric
=
load_metric
(
"accuracy"
)
...
...
examples/pytorch/language-modeling/run_mlm.py
View file @
c0281feb
...
@@ -477,6 +477,10 @@ def main():
...
@@ -477,6 +477,10 @@ def main():
eval_dataset
=
eval_dataset
.
select
(
range
(
data_args
.
max_eval_samples
))
eval_dataset
=
eval_dataset
.
select
(
range
(
data_args
.
max_eval_samples
))
def
preprocess_logits_for_metrics
(
logits
,
labels
):
def
preprocess_logits_for_metrics
(
logits
,
labels
):
if
isinstance
(
logits
,
tuple
):
# Depending on the model and config, logits may contain extra tensors,
# like past_key_values, but logits always come first
logits
=
logits
[
0
]
return
logits
.
argmax
(
dim
=-
1
)
return
logits
.
argmax
(
dim
=-
1
)
metric
=
load_metric
(
"accuracy"
)
metric
=
load_metric
(
"accuracy"
)
...
...
Write
Preview
Markdown
is supported
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