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

Exception has occurred: TypeError object of type 'NoneType' has no len() in learner_cls.py when do Model inference

Open ruianlc opened this issue 1 year ago • 1 comments

when load the local trained model, and do the model inference based on the given example, error occurs, below is the full information. anyone can helps, thanks.

Exception has occurred: TypeError object of type 'NoneType' has no len() File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fast-bert\fast_bert\learner_cls.py", line 344, in init t_total = len(train_dataloader) // self.grad_accumulation_steps * epochs File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fast-bert\fast_bert\learner_cls.py", line 245, in from_pretrained_model return BertLearner( File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fast-bert\fast_bert\prediction.py", line 66, in get_learner learner = BertLearner.from_pretrained_model( File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fast-bert\fast_bert\prediction.py", line 46, in init self.learner = self.get_learner() File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fastbert-multilable.py", line 141, in predict predictor = BertClassificationPredictor( File "E:\workspace\baseProject\code_repo\competitions\FastBERT-MutliLabel Text Classification\fastbert-multilable.py", line 164, in predict() TypeError: object of type 'NoneType' has no len()

ruianlc avatar Mar 13 '24 01:03 ruianlc

Hi @ruianlc I encountered the same problem after I upgraded the fast-bert package. It may be caused by upgrading this package, but I am not sure how I should change the code to aviod this issue. After so long, have you solved it?

XiaoxueWang1 avatar Dec 10 '24 14:12 XiaoxueWang1