I continue trying to replicate lesson3-imdb.ipynb of the new Fastai course. After making sure my Python version (3.6.8), Pytorch (1.0.0) and fastai (1.0.39) are correct, I have managed to create
a learner. However, when I run the learning rate finder it produces a size mismatch for the loss function:
ValueError: Expected input batch_size (20106) to match target batch_size (6).
(This is with batch size 12, if I use 6 then it complains of size 10053 vs 3.) What may I be doing wrong?
I am sorry if any of these questions are too basic, I am unsure if they better belong in the “beginner” category better.
Thanks, as always!
I solved the problem. It is a bit embarrassing, but since someone liked it post I will leave this here instead of deleting my question altogether.
Good news is: Lr_find works perfectly fine! Just be careful not to mix TextLMDataBunch.load and TextClasDataBunch.load
How did you solve this issue? I have a similar error when I run lr_find at the language model. Thanks a lot in advance.
Hi peppa. I can’t say much more really (specially not without seeing some of your code). But make sure that you are using the right data bunch when loading the data. For a language model it should be TextLMDataBunch.load. Do you have that right?
Thanks @Pablo. I’m using fastai 1.0.50.post1.
idata_lm = TextLMDataBunch.load(path, fname=‘data_clas_export.pkl’, bs = 16)
data_clas = TextClasDataBunch.load(path, fname=‘data_clas_export.pkl’, bs = 16)
Using TextLMDataBunch.load will have errors below.
FileNotFoundError Traceback (most recent call last)
----> 1 data_lm = TextLMDataBunch.load(path, fname=‘data_clas_export.pkl’, bs = 16)
2 data_clas = TextClasDataBunch.load(path, fname=‘data_clas_export.pkl’, bs = 16)
/home/application/anaconda/lib/python3.7/site-packages/fastai/text/data.py in load(cls, path, cache_name, processor, **kwargs)
load_data for data saved with v1.0.44 or later.""", DeprecationWarning)
169 cache_path = Path(path)/cache_name
–> 170 vocab = Vocab(pickle.load(open(cache_path/‘itos.pkl’,‘rb’)))
171 train_ids,train_lbls = np.load(cache_path/f’train_ids.npy’), np.load(cache_path/f’train_lbl.npy’)
172 valid_ids,valid_lbls = np.load(cache_path/f’valid_ids.npy’), np.load(cache_path/f’valid_lbl.npy’)
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/workspace/jiratickets/data/inp/tmp/itos.pkl’