Not always consider a local model a checkpoint in run_glue (#10517)

This commit is contained in:
Sylvain Gugger 2021-03-04 11:11:39 -05:00 коммит произвёл GitHub
Родитель 745ea78dcc
Коммит a5bd40b75c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -406,12 +406,15 @@ def main():
# Training
if training_args.do_train:
checkpoint = None
if last_checkpoint is not None:
checkpoint = last_checkpoint
elif os.path.isdir(model_args.model_name_or_path):
checkpoint = model_args.model_name_or_path
else:
checkpoint = None
# Check the config from that potential checkpoint has the right number of labels before using it as a
# checkpoint.
if AutoConfig.from_pretrained(model_args.model_name_or_path).num_labels == num_labels:
checkpoint = model_args.model_name_or_path
train_result = trainer.train(resume_from_checkpoint=checkpoint)
metrics = train_result.metrics