Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
702f5898
"git@developer.sourcefind.cn:orangecat/ollama.git" did not exist on "2cd11ae365a9423578069457312dce6b9e1e5a37"
Commit
702f5898
authored
Sep 27, 2019
by
VictorSanh
Browse files
fix input in run_glue for distilbert
parent
22d2fded
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
examples/run_glue.py
examples/run_glue.py
+4
-2
No files found.
examples/run_glue.py
View file @
702f5898
...
@@ -134,8 +134,9 @@ def train(args, train_dataset, model, tokenizer):
...
@@ -134,8 +134,9 @@ def train(args, train_dataset, model, tokenizer):
batch
=
tuple
(
t
.
to
(
args
.
device
)
for
t
in
batch
)
batch
=
tuple
(
t
.
to
(
args
.
device
)
for
t
in
batch
)
inputs
=
{
'input_ids'
:
batch
[
0
],
inputs
=
{
'input_ids'
:
batch
[
0
],
'attention_mask'
:
batch
[
1
],
'attention_mask'
:
batch
[
1
],
'token_type_ids'
:
batch
[
2
]
if
args
.
model_type
in
[
'bert'
,
'xlnet'
]
else
None
,
# XLM, DistilBERT and RoBERTa don't use segment_ids
'labels'
:
batch
[
3
]}
'labels'
:
batch
[
3
]}
if
args
.
model_type
!=
'distilbert'
:
inputs
[
'token_type_ids'
]
=
batch
[
2
]
if
args
.
model_type
in
[
'bert'
,
'xlnet'
]
else
None
# XLM, DistilBERT and RoBERTa don't use segment_ids
outputs
=
model
(
**
inputs
)
outputs
=
model
(
**
inputs
)
loss
=
outputs
[
0
]
# model outputs are always tuple in transformers (see doc)
loss
=
outputs
[
0
]
# model outputs are always tuple in transformers (see doc)
...
@@ -224,8 +225,9 @@ def evaluate(args, model, tokenizer, prefix=""):
...
@@ -224,8 +225,9 @@ def evaluate(args, model, tokenizer, prefix=""):
with
torch
.
no_grad
():
with
torch
.
no_grad
():
inputs
=
{
'input_ids'
:
batch
[
0
],
inputs
=
{
'input_ids'
:
batch
[
0
],
'attention_mask'
:
batch
[
1
],
'attention_mask'
:
batch
[
1
],
'token_type_ids'
:
batch
[
2
]
if
args
.
model_type
in
[
'bert'
,
'xlnet'
]
else
None
,
# XLM, DistilBERT and RoBERTa don't use segment_ids
'labels'
:
batch
[
3
]}
'labels'
:
batch
[
3
]}
if
args
.
model_type
!=
'distilbert'
:
inputs
[
'token_type_ids'
]
=
batch
[
2
]
if
args
.
model_type
in
[
'bert'
,
'xlnet'
]
else
None
# XLM, DistilBERT and RoBERTa don't use segment_ids
outputs
=
model
(
**
inputs
)
outputs
=
model
(
**
inputs
)
tmp_eval_loss
,
logits
=
outputs
[:
2
]
tmp_eval_loss
,
logits
=
outputs
[:
2
]
...
...
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