I am using TabularList to create dataloader from data frame
procs = [FillMissing, Categorify, Normalize]
dep_var = 'target'
valid_idx = range(len(train_df)-5000, len(train_df))
train_set = processed_data[:-2000]
test_set = processed_data[-2000:]
train_set.head()
It is printing data set
But when i do
data = (TabularList.from_df(train_set, path='./', procs=procs)
.split_by_idx(list(range(500,10000)))
.label_from_df(cols=dep_var)
.add_test(test_set, label=0)
.databunch())
learn4 = tabular_learner(data, layers=[450,200], metrics=accuracy)
Error showsup
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-80-1060327be70e> in <module>
----> 1 learn4 = tabular_learner(data, layers=[450,200], metrics=accuracy)
~/anaconda3/lib/python3.7/site-packages/fastai/tabular/learner.py in tabular_learner(data, layers, emb_szs, metrics, ps, emb_drop, y_range, use_bn, **learn_kwargs)
15 emb_szs = data.get_emb_szs(ifnone(emb_szs, {}))
16 model = TabularModel(emb_szs, len(data.cont_names), out_sz=data.c, layers=layers, ps=ps, emb_drop=emb_drop,
---> 17 y_range=y_range, use_bn=use_bn)
18 return Learner(data, model, metrics=metrics, **learn_kwargs)
19
~/anaconda3/lib/python3.7/site-packages/fastai/core.py in _init(self, *args, **kwargs)
64 def _init(self,*args,**kwargs):
65 self.__pre_init__()
---> 66 old_init(self, *args,**kwargs)
67 self.__post_init__()
68 x.__init__ = _init
~/anaconda3/lib/python3.7/site-packages/fastai/tabular/models.py in __init__(self, emb_szs, n_cont, out_sz, layers, ps, emb_drop, y_range, use_bn, bn_final)
20 layers = []
21 for i,(n_in,n_out,dp,act) in enumerate(zip(sizes[:-1],sizes[1:],[0.]+ps,actns)):
---> 22 layers += bn_drop_lin(n_in, n_out, bn=use_bn and i!=0, p=dp, actn=act)
23 if bn_final: layers.append(nn.BatchNorm1d(sizes[-1]))
24 self.layers = nn.Sequential(*layers)
~/anaconda3/lib/python3.7/site-packages/fastai/layers.py in bn_drop_lin(n_in, n_out, bn, p, actn)
46 layers = [nn.BatchNorm1d(n_in)] if bn else []
47 if p != 0: layers.append(nn.Dropout(p))
---> 48 layers.append(nn.Linear(n_in, n_out))
49 if actn is not None: layers.append(actn)
50 return layers
~/anaconda3/lib/python3.7/site-packages/torch/nn/modules/linear.py in __init__(self, in_features, out_features, bias)
75 else:
76 self.register_parameter('bias', None)
---> 77 self.reset_parameters()
78
79 def reset_parameters(self):
~/anaconda3/lib/python3.7/site-packages/torch/nn/modules/linear.py in reset_parameters(self)
78
79 def reset_parameters(self):
---> 80 init.kaiming_uniform_(self.weight, a=math.sqrt(5))
81 if self.bias is not None:
82 fan_in, _ = init._calculate_fan_in_and_fan_out(self.weight)
~/anaconda3/lib/python3.7/site-packages/torch/nn/init.py in kaiming_uniform_(tensor, a, mode, nonlinearity)
322 fan = _calculate_correct_fan(tensor, mode)
323 gain = calculate_gain(nonlinearity, a)
--> 324 std = gain / math.sqrt(fan)
325 bound = math.sqrt(3.0) * std # Calculate uniform bounds from standard deviation
326 with torch.no_grad():
ZeroDivisionError: float division by zero
What is going wrong ? i have no clue