Lesson 1: NameError: name 'cnn_learner' is not defined

(Abhishek Velidi) #1

Hi,

I am getting the following error in Lesson 1
image

Thanks,
Abhishek

1 Like

(Shahbaz Khan) #2

Hey @velidia
I got the same error a while ago.
My version of fastai is 1.0.46
I checked list of methods available for fastai.vision using dir(), and figured out that the method available to create CNN learner is create _cnn, and not cnn_learner.
I tried the same and overcame the error. It’s working now.
So go ahead and replace cnn_learner with create _cnn

Cheers !

2 Likes

#3

This is the correct answer. You can find breaking changes on the fastai v1 GitHub page under “changes”

0 Likes

#4

There is also a topic with all the announcements you should follow

1 Like

(Abhishek Velidi) #5

Hey shahbazkhan185,
Changing cnn_learner to create_cnn worked. Thanks!

2 Likes

#6

Better use:
!pip install --no-deps fastai==1.0.47 to grab the version where it works, or later version.

0 Likes

(Patrick Trampert) #7

Adding ‘deprecated’ messages and supporting the old and the new version, at least for refactorings in terms of naming, are in general a good way to prevent such problems.

The message will then tell you, what changed, so that you can adapt the code.

1 Like

(David Wolpe) #8

@sgugger I believe that’s backwards in the .md file:

1.0.47 (2019-03-06)

Breaking changes:

  • create_cnn becomes cnn_learner

Shouldn’t it be

  • cnn_learner becomes create_cnn

If so let me know if you’d like to me to create a branch and a PR for this

0 Likes

#9

No, it’s the right way: there is no create_cnn anymore, and it’s cnn_learner that should be used.

0 Likes

(David Wolpe) #10

Errr… that’s the opposite of my experience just now, and what the others above seem to be saying. Unless I should do a pull/update, which I’ll try.

0 Likes

(Ashray Aggarwal) #11

Yes create_cnn works instead of cnn_learner.

0 Likes

(Bernd Heidemann) #12

If create_cnn works you have an older version of fastai installed. In the current version of fastai it’s cnn_learner

0 Likes

(David Wolpe) #13

Well I figured this out. It has to do with git pull not updating correctly. I first tried

cd course-v3
git pull

and it did update some files. However, it still only worked with create_cnn (even after shutting down and restarting the paperspace machine).

I then looked at the conda tab in the Jupyter notebook:

23%20PM

So I went to /opt/conda/envs/fastai in a new terminal window

From within that folder I ran:

conda install -c fastai fastai

After the installation I launched python with the python3 command. I was then able to run

import fastai; fastai.__version__

and the version which had been 1.0.42 is now showing as 1.0.50.

Running the notebook confirmed that create_cnn no longer works, and cnn_learner does work.

(Note to admin: some of this I’ve duplicated from the paperspace thread; there were related questions both here and there).

0 Likes

(Raveen Beemsingh) #14

I confirm this works, thanks for the help

0 Likes