EasyNLP icon indicating copy to clipboard operation
EasyNLP copied to clipboard

Failed to run example script for sequence_classification_multilabel: Target size (torch.Size([32])) must be the same as input size (torch.Size([32, 27]))

Open Chen9154 opened this issue 2 years ago • 0 comments

I copy the training command from here and modify a little.

python -m torch.distributed.launch $DISTRIBUTED_ARGS main.py \ --mode train \ --tables=train.csv,dev.csv \ --input_schema=content_seq:str:1,label:str:1 \ --first_sequence=content_seq \ --label_name=label \ --label_enumerate_values=母婴,三农,科学,美文,科技,时尚,房产,美食,艺术,职场,健康,财经,国际,家居,娱乐,文化,教育,游戏,读书,动漫,体育,旅游,汽车,搞笑,健身,宠物,育儿 \ --checkpoint_dir=./multi_label_classification_model \ --learning_rate=3e-5 \ --epoch_num=1 \ --random_seed=42 \ --save_checkpoint_steps=100 \ --sequence_length=128 \ --train_batch_size=32 \ --app_name=text_classify \ --user_defined_parameters=' pretrain_model_name_or_path=hfl/chinese-roberta-wwm-ext multi_label=True '

And here's the error stack. image

It seems the Target has a wrong size (torch.Size([32])) which should be torch.Size([32, 27]) under the multilabel settings.

Chen9154 avatar Jul 05 '22 08:07 Chen9154