hi,
I am new to NLP. And, I am trying to replicate the results in fastai/courses/dl2/imdb.ipynb.
when I try to execute
trn_dl = LanguageModelLoader(np.concatenate(trn_lm), bs, bptt)
I get below error:
AttributeError: ‘numpy.int64’ object has no attribute ‘text’
It seems a valid error since trn_lm is having only numbers.
trn_lm = np.array([[stoi[o] for o in p] for p in tok_trn])
Has anyone come across this error before? Please let me know how to resolve this
i looked at LanguageModelLoader class definition.I am not sure where ‘o.text’ is coming from.
Class DataLanugageLoader():
def __init__(self, ds, bs, bptt, backwards=False): self.bs,self.bptt,self.backwards = bs,bptt,backwards text = sum([o.text for o in ds], []) fld = ds.fields['text'] nums = fld.numericalize([text],device=None if torch.cuda.is_available() else -1) self.data = self.batchify(nums) self.i,self.iter = 0,0 self.n = len(self.data)
P.S. I did not install fastai v 0.7. Instead I am using only those functions which are required to execute the code in IMDB notebook.