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
f69dbecc
Commit
f69dbecc
authored
Dec 12, 2019
by
Morgan Funtowicz
Browse files
Expose classification labels mapping (and reverse) in model config.
parent
6709739a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
transformers/configuration_utils.py
transformers/configuration_utils.py
+2
-0
No files found.
transformers/configuration_utils.py
View file @
f69dbecc
...
...
@@ -58,6 +58,8 @@ class PretrainedConfig(object):
self
.
use_bfloat16
=
kwargs
.
pop
(
'use_bfloat16'
,
False
)
self
.
pruned_heads
=
kwargs
.
pop
(
'pruned_heads'
,
{})
self
.
is_decoder
=
kwargs
.
pop
(
'is_decoder'
,
False
)
self
.
idx2label
=
kwargs
.
pop
(
'idx2label'
,
{
i
:
'LABEL_{}'
.
format
(
i
)
for
i
in
range
(
self
.
num_labels
)})
self
.
label2idx
=
kwargs
.
pop
(
'label2idx'
,
dict
(
zip
(
self
.
idx2label
.
values
(),
self
.
idx2label
.
keys
())))
def
save_pretrained
(
self
,
save_directory
):
""" Save a configuration object to the directory `save_directory`, so that it
...
...
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