Lesson 2 discussion

(Jeremy Howard) #1

Please ask questions or add your comments and help regarding lesson 2 here.

Start by reading the Lesson 2 wiki page.

How to modify the get_batches generator to provide labels for Regression
(Jeremy Howard) #2

There are some fantastic readings that cover similar material to this week’s course. I’ve added them to the lesson wiki page. In particular, the Stanford CNN course is some of the best technical writing I’ve seen, and is totally up to date. If you have 8 hours to spend this week, spending half that time reading the Stanford notes would be an excellent use of your time this week.

(Brendan Fortuner) #3

Running the sgd-intro.ipynb file returned an error for me when generating the animation.

You can fix this on Ubuntu by downloading ffmpeg:

sudo apt-get install ffmpeg

(leahob) #4

I get a 403 error when downloading the xl files from the platform.ai site


wget http://www.platform.ai/files/xl/layers_example.xlsx
–2016-11-02 17:08:46-- http://www.platform.ai/files/xl/layers_example.xlsx
Resolving www.platform.ai (www.platform.ai)…
Connecting to www.platform.ai (www.platform.ai)||:80… connected.
HTTP request sent, awaiting response… 403 Forbidden
2016-11-02 17:08:46 ERROR 403: Forbidden

You don’t have permission to access /files/xl/layers_example.xlsx on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

(Brendan Fortuner) #5

403 Forbidden when trying to open the Excel files after download

You don’t have permission to access /files/xl/entropy_example.xlsx on this server.

I think Jeremy might need to fix this one:

(Jeremy Howard) #6

@brendan @leahob oops sorry! fixed now

(mattobrien415) #7

Has anyone had any trouble with the

The line
from tensorflow.examples.tutorials.mnist import input_data

is generating, for me, an error:
ImportError: No module named tensorflow.examples.tutorials.mnist

It looks like this might be a path issue or something. But I’m not sure how to correct it. I usually blindly trust pip for installs…not really clear on how the guts of accessing libraries work in Python.

  • I know I have tensorflow installed. It lives here:

  • I am using the Anaconda kernel with the Jupyter notebook

  • even a basic import fails. This fails:
    import tensorflow as tf

Does anyone have any recommendation? Thanks.

(Rachel Thomas) #8

@mattobrien415 You need to install tensorflow with Anaconda (which is using a different python installation than your system one), since you’re trying to use it with the Anaconda kernel

(vedshetty) #9

So we call model.pop() and remove the last layer and then add a dense layer to predict for cats/dogs. We then call model.fit() to calculate the weights of this last layer only using the precalculated weights of the other 15 layers (right?) … how do we control the fact that model.fit() is only calculating weights for the last layer (output layer)?

Edit: Solved!
From this: for layer in model.layers: layer.trainable=False

(mattobrien415) #10

I only switched to Ananconda as an attempt to fix the problem. Either kernel, I get the same error. Hummmm…

(vedshetty) #11

I am trying to confirm the direction of the chain rule for backprop - When you are calculating gradients for Backprop at a particular hidden layer say 10, are we considering layers 1-10 or 10-16? I am assuming it is the former?

Also here:

layers = model.layers
# Get the index of the first dense layer...
first_dense_idx = [index for index,layer in enumerate(layers) if type(layer) is Dense][0]
# ...and set this and all subsequent layers to trainable
for layer in layers[first_dense_idx:]: layer.trainable=True

we are calculating new weights for every layer. And once again calculating new weights for layers 12-16 onwards?:

for layer in layers[12:]: layer.trainable=True

So it looks like we can randomly choose layers again to recalculate weights. Is there a benefit of performing a backprop immediately after another backprop operation especially in the example the model architecture has remained unchanged after the first backpop?

(Jeremy Howard) #12

@vshets the chain rules works backwards - that is, you can’t calculate the gradients for layer 15 without first knowing layer 16, etc. In practice, you don’t have to worry about this, since theano handles it automatically.

Note the colon in ‘layers[12:]’. That is, we’re setting layer 12 and every layer after it to trainable. (They were originally set to non-trainable by vgg16.finetune()).

(sethiavivek2006) #13

@jeremy @all I was reading Stanford CNN Course for Stochastic Gradient Descent but was not able to follow it. Is there anything else which I need to read before taking this up ?

(Jeremy Howard) #14

@sethiavivek2006 we’ll be discussing backprop this week! :slight_smile:

(brianorwhatever) #15

FYI if anyone else runs into this problem you will have to restart your jupyter notebook

(vedshetty) #16

I read this and thought it was useful especially the beginners guide to CNN… https://adeshpande3.github.io/adeshpande3.github.io/

(melissa.fabros) #17

i was getting an error with sudo apt-get install ffmpeg
Package 'ffmpeg' has no installation candidate

I found if you have ubuntu 14 or 15 this might help?

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

(sravya8) #18

I am doing the cats and dogs redux. And I get the following error when I do a fit
Exception: Error when checking model target: expected dense_10 to have shape (None, 2) but got array with shape (50, 3)

Has any one else seen this? This thread discusses similar problem: https://github.com/fchollet/keras/issues/3009 But not sure where I need to do the reshape. Not sure if it matters but I did abort one of the previous fit() function call as I was intending to run it on sample but ended up running on actual data. Could the abort be causing this issue?

(sethiavivek2006) #20

Thank you , will look forward for it.

(Jeremy Howard) #21

@sravya8 hard to know what’s happening without seeing the context. See http://wiki.fast.ai/index.php/How_to_ask_for_Help for tips on the kind of info we’ll need to be able to help you.

(The error message is showing that for some reason your model’s last layer has 3 outputs, rather than 2. )