Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: object of type 'NoneType' has no len() #6

Open
gdet opened this issue Jan 27, 2021 · 0 comments
Open

TypeError: object of type 'NoneType' has no len() #6

gdet opened this issue Jan 27, 2021 · 0 comments

Comments

@gdet
Copy link

gdet commented Jan 27, 2021

Hello everyone,

I am trying to finetune the GPT-2 model following this code https://github.com/piegu/fastai-projects/blob/master/finetuning-English-GPT2-any-language-Portuguese-HuggingFace-fastaiv2_FAST.ipynb . And I have this error before dataloaders:

 Traceback (most recent call last):
   File "fastaitokenizer.py", line 249, in <module>
     dls = tls.dataloaders(bs=bs, seq_len=sl)
   File "/home/myuser/.conda/envs/fastai2/lib/python3.8/site-packages/fastai2/data/core.py", line 203, in dataloaders
     dl = dl_type(self.subset(0), bs=bs, shuffle=shuffle_train, drop_last=drop_last, n=n, device=device,
   File "/home/myuser/.conda/envs/fastai2/lib/python3.8/site-packages/fastcore/utils.py", line 454, in _f
     return inst if to_return else f(*args, **kwargs)
   File "/home/myuser/.conda/envs/fastai2/lib/python3.8/site-packages/fastai2/text/data.py", line 92, in __init__
     lens = [len(o) for o in self.items if str(o)!='nan']
   File "/home/myuser/.conda/envs/fastai2/lib/python3.8/site-packages/fastai2/text/data.py", line 92, in <listcomp>
     lens = [len(o) for o in self.items if str(o)!='nan']
 TypeError: object of type 'NoneType' has no len()

The error is in all data code section not in sample data section. In sample data code section where you test your code I have no error.
What could be the problem?
I opened the file /home/myuser/.conda/envs/fastai2/lib/python3.8/site-packages/fastai2/text/data.py and added if o is none to add len(o) as zero but then I have an error about the size of the tensors. Something like:

RuntimeError: stack expects each tensor to be equal size, but got [1024] at entry 1 and [962] at entry 2

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant