Hi!
When following along the tabular data inference tutorial (https://docs.fast.ai/tutorial.inference.html) I found an error. I am using fastai==1.0.36.post1.
Code that generates the error:
from fastai import *
from fastai.tabular import *
adult = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(adult/'adult.csv')
dep_var = '>=50k'
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race', 'sex', 'native-country']
cont_names = ['education-num', 'hours-per-week', 'age', 'capital-loss', 'fnlwgt', 'capital-gain']
procs = [FillMissing, Categorify, Normalize]
data = (TabularList.from_df(df, path=adult, cat_names=cat_names, cont_names=cont_names, procs=procs)
.split_by_idx(valid_idx=range(800,1000))
.label_from_df(cols=dep_var)
.databunch())
learn = tabular_learner(data, layers=[20,10], metrics=accuracy)
learn.fit(1, 1e-2)
learn.save('mini_train')
data = TabularDataBunch.load_empty(adult)
learn = tabular_learner(data, layers=[20,10])
learn.load('mini_train');
I get the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-664f9a90ba78> in <module>
18 learn.save('mini_train')
19
---> 20 data = TabularDataBunch.load_empty(adult)
21 learn = tabular_learner(data, layers=[20,10])
22 learn.load('mini_train');
/private/tmp/fastai-inference/venv/lib/python3.7/site-packages/fastai/data_block.py in _databunch_load_empty(cls, path, fname, tfms, tfm_y, **kwargs)
548 def _databunch_load_empty(cls, path, fname:str='export.pkl', tfms:TfmList=None, tfm_y:bool=False, **kwargs):
549 "Load an empty `DataBunch` from the exported file in `path/fname` with optional `tfms`."
--> 550 sd = LabelLists.load_empty(path/fname, tfms=tfms, tfm_y=tfm_y, **kwargs)
551 return sd.databunch()
552
/private/tmp/fastai-inference/venv/lib/python3.7/site-packages/fastai/data_block.py in load_empty(cls, fn, tfms, tfm_y, **kwargs)
446 @classmethod
447 def load_empty(cls, fn:PathOrStr, tfms:TfmList=None, tfm_y:bool=False, **kwargs):
--> 448 train_ds = LabelList.load_empty(fn, tfms=tfms[0], tfm_y=tfm_y, **kwargs)
449 valid_ds = LabelList.load_empty(fn, tfms=tfms[1], tfm_y=tfm_y, **kwargs)
450 return LabelLists(valid_ds.path, train=train_ds, valid=valid_ds)
TypeError: 'NoneType' object is not subscriptable