"examples/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "8a38a7b1c462a282178466edcd1d7325ca004a23"
Commit 751a1e08 authored by Julien Chaumond's avatar Julien Chaumond
Browse files

[config] Ensure that id2label always takes precedence over num_labels

Fixes bug reported in https://github.com/huggingface/transformers/issues/4669

See #3967 for context
parent ec62b7d9
...@@ -89,6 +89,7 @@ class PretrainedConfig(object): ...@@ -89,6 +89,7 @@ class PretrainedConfig(object):
self.id2label = kwargs.pop("id2label", None) self.id2label = kwargs.pop("id2label", None)
self.label2id = kwargs.pop("label2id", None) self.label2id = kwargs.pop("label2id", None)
if self.id2label is not None: if self.id2label is not None:
del kwargs["num_labels"]
self.id2label = dict((int(key), value) for key, value in self.id2label.items()) self.id2label = dict((int(key), value) for key, value in self.id2label.items())
# Keys are always strings in JSON so convert ids to int here. # Keys are always strings in JSON so convert ids to int here.
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment