File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed
pytorch/text-classification
tensorflow/text-classification Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,9 @@ def main():
380
380
if label_to_id is not None :
381
381
model .config .label2id = label_to_id
382
382
model .config .id2label = {id : label for label , id in config .label2id .items ()}
383
+ elif data_args .task_name is not None and not is_regression :
384
+ model .config .label2id = {l : i for i , l in enumerate (label_list )}
385
+ model .config .id2label = {id : label for label , id in config .label2id .items ()}
383
386
384
387
if data_args .max_seq_length > tokenizer .model_max_length :
385
388
logger .warning (
Original file line number Diff line number Diff line change @@ -288,6 +288,9 @@ def main():
288
288
if label_to_id is not None :
289
289
model .config .label2id = label_to_id
290
290
model .config .id2label = {id : label for label , id in config .label2id .items ()}
291
+ elif args .task_name is not None and not is_regression :
292
+ model .config .label2id = {l : i for i , l in enumerate (label_list )}
293
+ model .config .id2label = {id : label for label , id in config .label2id .items ()}
291
294
292
295
padding = "max_length" if args .pad_to_max_length else False
293
296
Original file line number Diff line number Diff line change @@ -355,6 +355,9 @@ def main():
355
355
if label_to_id is not None :
356
356
config .label2id = label_to_id
357
357
config .id2label = {id : label for label , id in config .label2id .items ()}
358
+ elif data_args .task_name is not None and not is_regression :
359
+ config .label2id = {l : i for i , l in enumerate (label_list )}
360
+ config .id2label = {id : label for label , id in config .label2id .items ()}
358
361
359
362
if data_args .max_seq_length > tokenizer .model_max_length :
360
363
logger .warning (
You can’t perform that action at this time.
0 commit comments