Applying ULMfit on custom data



I was trying to apply the following code

and I was successful running the code in its own but when I switched in my data there seems to be this error coming up. Any assistance will be appreciated.

data_lm_lab = TextLMDataBunch.from_csv('', 'text_data.csv')

learn = language_model_learner(data_lm_lab, pretrained_model=URLs.WT103, drop_mult=0.7)

learn.fit_one_cycle(1, 1e-2)


This is what the data looks like


I get the following error

> /usr/local/lib/python3.6/dist-packages/fastai/ in validate(model, dl, loss_func, cb_handler, pbar, average, n_batch)
>      55             if n_batch and (len(nums)>=n_batch): break
>      56         nums = np.array(nums, dtype=np.float32)
> ---> 57         if average: return (to_np(torch.stack(val_losses)) * nums).sum() / nums.sum()
>      58         else:       return val_losses
>      59 
> RuntimeError: expected a non-empty list of Tensors


Hi @m_jahangeer

Could you also share a sample of your dataset? It will help in solving this issue.



Thanks mate heres a sample dataset

ulmfit.csv (48.3 KB)


Hi @m_jahangeer

The code is working fine with your sample dataset. You can refer to the attached notebook. (4.7 KB)


Thanks a lot mate, but if I may what version of the fast ai library are you using?


Never mind mate, Thanks a lot I got it to work, Many thanks mate.