Unfamiliar Error when Running learn.fit()

I face the same issue trying to learn resnet34 on my own dataset.

I just hit this problem today.

I looking at the numpy release notes, version 1.16.0 was released just over a week ago.

Downgrading my install to numpy=1.15.1 resolved this issue with the learn.fit methods in fast.ai


This setup did it for me

!pip install Pillow==4.1.1
!pip install fastai==0.7.0 
!pip install torchtext==0.2.3
!pip install blosc

I’ve created a jupyter notebook locally and everything worked (fastai 0.7 I guess), afterwards uploaded notebook on kaggle and I got the same error. I tried to change numpy version but then I get a different error when importing fastai. I’m pretty sure this error is caused due to the wrong version of numpy, but can’t find a solution. Previously I tried 1.15.1 and 1.15.3 with the same outcome.
The stack trace is quite long so don’t want to upload it all, but before the part on the screenshot, statsmodel package is imported which imports numpy. The problem might be that kaggle has both conda and pip, whereas I checked that Collab only used pip. Also I checked in numpy repo that parameter _typestr was deleted in numpy 1.16.0

Would be great if I got the solution before 30th January bc that day the competition ends.

Facing the same issue!
Please reply if somebody has solved this, thanks in advance.

1 Like

I tried following the suggestions from Cesare:

!pip install Pillow==4.1.1
!pip install fastai==0.7.0
!pip install torchtext==0.2.3
!pip install blosc
But I am still getting the exact same error when I run learn.fit()
AttributeError: ‘list’ object has no attribute 'round
AttributeError: ‘float’ object has no attribute ‘rint’

Same here, for some notebooks it works, on some others trigger that error.
My choice is to go for the version 3 of the course :wink:

Installing numpy 1.15.1 solved the problem:

!pip intall numpy==1.15.1

Credit to: Error in learn.fit() lesson 1


I’m still facing the same issue. Any final solution that works?

Please may i know what was the pytorch version you used?

I got stuck on this too with the fastai/courses/dl2/carvana.ipynb notebook.

Following on what the other commenters have mentioned, I went into my fastai/environment.yml file and changed the two entries for numpy from just - numpy to - numpy=1.15.1. After that I ran the command conda env update -f environment.yml and that fixed this error.


This worked for me (I was running on cpu, and haven’t tried the gpu one):
conda env remove -y -n fastai-cpu (conda env remove -y -n fastai for the gpu version)
Then open fastai/environment-cpu.yml (fastai/environment.yml for the gpu version) and change the - numpy under dependencies to - numpy<=1.15.1 then save and redo the environment setup which is cd fastai then
conda env create -f environment-cpu.yml (for gpu version conda env create -f environment.yml) and then conda activate fastai-cpu. Now run jupyter notebook and things should work normal.


Thank you too mucn. I changed numpy=1.16.2 to numpy=1.15.1. So I solved the error “AttributeError: ‘float’ object has no attribute ‘rint’ ”

1 Like

hi all,
Did you finish running the file dl2/imdb.ipynb. can you share me the model output such as lm_last_ft, lm1, lm1_enc, clas_0, clas_1, clas_2 …
It took me a lot of days to run all of the fit() commands, please help me if you have these model files, thanks.

Hi blazjd,

Please did you find solution to this problem? I’m facing the same challenge now using colab. Non of the suggested solution here worked for me.


How I solved it: the rounding is happening in the model.py file at two places to make the printed output more readable. It seemed a luxury to me at the cost of the fit function failing. I removed the round off happening at the two places and it worked fine. Here are the two edits:

line 194, make it: values = [epoch] + list(values)

line 184, make it: ep_vals[epoch]=list(values)

Downgrading numpy as a solution doesn’t solve the problem entirely since then np.stack starts creating an issue. More so because one wouldn’t be sure where else an older numpy version shall throw errors.
Altering the source code was hence the only option.


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