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
139e8301
Unverified
Commit
139e8301
authored
Aug 30, 2021
by
Sylvain Gugger
Committed by
GitHub
Aug 30, 2021
Browse files
Update label2id in the model config for run_glue (#13334)
parent
6f3c99ac
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
0 deletions
+9
-0
examples/pytorch/text-classification/run_glue.py
examples/pytorch/text-classification/run_glue.py
+3
-0
examples/pytorch/text-classification/run_glue_no_trainer.py
examples/pytorch/text-classification/run_glue_no_trainer.py
+3
-0
examples/tensorflow/text-classification/run_glue.py
examples/tensorflow/text-classification/run_glue.py
+3
-0
No files found.
examples/pytorch/text-classification/run_glue.py
View file @
139e8301
...
...
@@ -380,6 +380,9 @@ def main():
if
label_to_id
is
not
None
:
model
.
config
.
label2id
=
label_to_id
model
.
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
elif
data_args
.
task_name
is
not
None
and
not
is_regression
:
model
.
config
.
label2id
=
{
l
:
i
for
i
,
l
in
enumerate
(
label_list
)}
model
.
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
if
data_args
.
max_seq_length
>
tokenizer
.
model_max_length
:
logger
.
warning
(
...
...
examples/pytorch/text-classification/run_glue_no_trainer.py
View file @
139e8301
...
...
@@ -288,6 +288,9 @@ def main():
if
label_to_id
is
not
None
:
model
.
config
.
label2id
=
label_to_id
model
.
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
elif
args
.
task_name
is
not
None
and
not
is_regression
:
model
.
config
.
label2id
=
{
l
:
i
for
i
,
l
in
enumerate
(
label_list
)}
model
.
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
padding
=
"max_length"
if
args
.
pad_to_max_length
else
False
...
...
examples/tensorflow/text-classification/run_glue.py
View file @
139e8301
...
...
@@ -355,6 +355,9 @@ def main():
if
label_to_id
is
not
None
:
config
.
label2id
=
label_to_id
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
elif
data_args
.
task_name
is
not
None
and
not
is_regression
:
config
.
label2id
=
{
l
:
i
for
i
,
l
in
enumerate
(
label_list
)}
config
.
id2label
=
{
id
:
label
for
label
,
id
in
config
.
label2id
.
items
()}
if
data_args
.
max_seq_length
>
tokenizer
.
model_max_length
:
logger
.
warning
(
...
...
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