From ec8717d5d8f6edc2c595ff6954ffaa2078dcc97d Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Mon, 1 Jun 2020 16:54:55 +0200 Subject: [PATCH] [config] Ensure that id2label always takes precedence over num_labels --- src/transformers/configuration_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/configuration_utils.py b/src/transformers/configuration_utils.py index fb63a94646..56a1a16925 100644 --- a/src/transformers/configuration_utils.py +++ b/src/transformers/configuration_utils.py @@ -89,7 +89,7 @@ class PretrainedConfig(object): self.id2label = kwargs.pop("id2label", None) self.label2id = kwargs.pop("label2id", None) if self.id2label is not None: - del kwargs["num_labels"] + kwargs.pop("num_labels", None) 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. else: