Unfamiliar Error when Running learn.fit()

@debprotim
Thanks man this really helped.

For others who are facing problem in “fit” function of fastai model.py try making changes in the source code as suggested by debprotim than downgrading numpy.

Thanks it worked for me.
I made changes debprotim mentioned on line no 184 and line no 189 instead of 194.

Actually, there is a way to preserve the rounding. Just use the following substitution:

If L is a list, then replace “np.round(L, decimals)” with “np.round(list(map(float,L)), decimals)”

How can I edit the source code? When I make the changes you stated, the code runs as if the changes were not made.
Note: I am using Google Colab and have setup fastai with the following:

!pip install torchvision==0.1.9
!pip install fastai==0.7.0
!pip install torchtext==0.2.3

I had to clone fastai, make the code change, then install.

  1. !git clone https://github.com/fastai/fastai.git
  2. Make the code change.
  3. !pip install .

I get the error AttributeError: ‘numpy.float64’ object has no attribute ‘func’:


AttributeError Traceback (most recent call last)
in ()
1 learn = tabular_learner(data, layers = [512, 256], metrics = accuracy)
----> 2 learn.fit(1, 1e-5)
4 frames
in init(self, callbacks, metrics, beta)
/usr/local/lib/python3.6/dist-packages/fastai/callback.py in init(self, func)
330 def init(self, func):
331 # If func has a name use this one else it should be a partial
–> 332 name = func.name if hasattr(func, ‘name’) else func.func.name
333 self.func, self.name = func, name
334 self.world = num_distrib()
AttributeError: ‘numpy.float64’ object has no attribute ‘func’

When running the * learn.fit()* method.

I am working in a Google Colab environment, so wondering if anybody has any suggestions as to how to fix this?

My feature types are as following:
bool x 32
int64 x 13
int16 x 1

Continuous variables are int64s only, while the categorical variables are a combination.

Code:

procs = [FillMissing, Categorify, Normalize]
valid_idx = range(2000, 4000)
data = (TabularList.from_df(df_copy_classification, cat_names=cat_vars, procs=procs).split_by_idx(valid_idx=valid_idx).label_from_df(cols = dep_var).databunch())
learn = tabular_learner(data, layers = [512, 256], metrics = accuracy)
learn.fit(1, 1e-5)