fast-bert icon indicating copy to clipboard operation
fast-bert copied to clipboard

Some errors about multilabel classification in Chinese

Open lpl22-github opened this issue 5 years ago • 4 comments

I run the example called 'new-toxic-multilabel.ipynb' in English and that's all right. After changing the file in Chinese with the same format , I got such errors :(

learner.fit(args.num_train_epochs, args.learning_rate, validate=True)

./models/output/tensorboard Selected optimization level O1: Insert automatic casts around Pytorch functions and Tensor methods.

Defaults for this optimization level are: enabled : True opt_level : O1 cast_model_type : None patch_torch_functions : True keep_batchnorm_fp32 : None master_weights : None loss_scale : dynamic Processing user overrides (additional kwargs that are not None)... After processing overrides, optimization options are: enabled : True opt_level : O1 cast_model_type : None patch_torch_functions : True keep_batchnorm_fp32 : None master_weights : None loss_scale : dynamic 10/25/2019 22:46:36 - INFO - root - ***** Running training ***** 10/25/2019 22:46:36 - INFO - root - Num examples = 1001 10/25/2019 22:46:36 - INFO - root - Num Epochs = 6 10/25/2019 22:46:36 - INFO - root - Total train batch size (w. parallel, distributed & accumulation) = 8 10/25/2019 22:46:36 - INFO - root - Gradient Accumulation steps = 1 10/25/2019 22:46:36 - INFO - root - Total optimization steps = 756 0.00% [0/6 00:00<00:00]

Interrupted

RuntimeError Traceback (most recent call last) in () ----> 1 learner.fit(args.num_train_epochs, args.learning_rate, validate=True)

2 frames /usr/local/lib/python3.6/dist-packages/fast_bert/modeling.py in forward(self, input_ids, token_type_ids, attention_mask, labels, position_ids, head_mask) 165 166 loss = loss_fct(logits.view(-1, self.num_labels), --> 167 labels.view(-1, self.num_labels)) 168 outputs = (loss,) + outputs 169

RuntimeError: shape '[-1, 82]' is invalid for input of size 648

lpl22-github avatar Oct 25 '19 23:10 lpl22-github

delete the cache

patronum08 avatar Dec 26 '19 06:12 patronum08

@lpl22-github I'm getting the same error on Urdu dataset, did you happen to resolve this ?

@charon0808 you mean use clear_cache=True in the BertDataBunch ?

mohammedayub44 avatar Apr 15 '20 10:04 mohammedayub44

@lpl22-github I'm getting the same error on Urdu dataset, did you happen to resolve this ?

@charon0808 you mean use clear_cache=True in the BertDataBunch ?

I mean delete the cache file in your project

patronum08 avatar Apr 15 '20 10:04 patronum08

Thanks. @charon0808 Also, it was a mismatch of classes.. the sample notebook file in sample_notebooks folder was helpful. Although i get some errors in saving the model which i posted another issue for.

mohammedayub44 avatar Apr 15 '20 16:04 mohammedayub44