Lesson 1 discussion

I do some GPU work (time series modelling) with my own server (256GB and 4 Titan X). Am wondering if doing it on AWS is a requirement or can I do the same locally? I have anaconda3 installed and am ew to Python…

I just watched the first lecture and it is fantastic. FastAI will go down as a big factor in democratizing AI…

Thank You.

Hi ormkel,

Thank for your reply.

I didn’t make myself clear in my previous post. I tried all combinations with ctrl + b + ", ctrl + b + % , ctrl + b + dbut they don’t work and made error/warning sound from mac. The only thing works is ctrl + d to exit tmux.

Do you know why and how to solve it?

Thanks

As far as I can tell AWS isn’t a requirement, just what the course was built around since its easy and relatively cheap. I got lesson 1 running really easy on an old CentOS Server I have around for file storage.

just to be clear, these are not combinations. you rather press ctrl + b to activate the command mode, then you press d. not at the same time

the command mode is, as far as i can see, not visibly different from before (in my iterm2 at least). no indication of that. Meaning you wont see any difference in tmux telling you that its active, just try it

2 Likes

Here are a couple of steps that helped me:

  1. I installed both the t2 and p2 scripts provided

  2. Got some errors along the way about cannot find cv2 I opened up the utils file and commented out the line that imports it import cv2

  3. Was still getting errors when I was running the first vgg = Vgg16() line did more investigation with the setups of the keras and theano and everything seemed fine, it turned out that the setup for the t2 was for a micro instance not large so I changed the instance type in the GUI in the AWS console.

  4. Yet again was still getting an error about path, just added a trailing slash to path = "data/dogscats/sample/" and it worked!

I am still getting a red error whenever I run vgg = Vgg16():

/home/ubuntu/anaconda2/lib/python2.7/site-packages/keras/layers/core.py:577: UserWarning: `output_shape` argument not specified for layer lambda_5 and cannot be automatically inferred with the Theano backend. Defaulting to output shape `(None, 3, 224, 224)` (same as input shape). If the expected output shape is different, specify it via the `output_shape` argument.
  .format(self.name, input_shape))

I am ignoring it for now since the rest of the code samples in the blocks work as expected.
Hope this helps someone!

3 Likes

In Lesson 1, the magic function of “finetune()” can turn into the original 1000-class output to a 2-class (dog and cat) classification. How is this achieved? Could somebody shed some light on this? If the original model is trained on 1000 classes, how can it generate only 2-class output? Very curious. Thank you.

1 Like

Also, every time when I run the last part of the tutorial, i got different results. and They are different from what’s posted on the Notebook as below:

Shape: (4, 1000)
First 5 classes: [u’tench’, u’goldfish’, u’great_white_shark’, u’tiger_shark’, u’hammerhead’]
First 5 probabilities: [ 7.6208e-07 6.8530e-07 1.0787e-06 3.1267e-06 9.2951e-06]

Predictions prob/class:
0.6808/schipperke
0.7532/beagle
0.3590/tabby
0.5831/schipperke
In [ ]:

Is this because of the ‘shuffle=true’ in the ‘get_batches’ function? Just want to make sure about this.

1 Like

Hi @jeremy, is fine tie something similar to the concept of Transfer Learning , where we only retrain the last 2-3 layers of the CNN , or is it something different that happens in the fine tune method. I am still in the first lecture, hence not jumped ahead in the lecture, if it is answered in the later lectures I can read / learn it in the forthcoming lectures.

Transfer Learning is described here http://cs231n.github.io/transfer-learning/

1 Like

This may be similar to the Transfer Learning methods, this may help

http://cs231n.github.io/transfer-learning/

1 Like

Thanks @ormkel, I did exactly as you suggeted above, but still the same, not working. Is it possible that tmux config is different on my mac? If so, I don’t know where and how to find it, do you know?

While tmux problem may need more time to solve, I wonder Is it possible for me to open two terminal windows without using tmux? Do you have any idea about it?

Thanks a lot

you can always open a new ssh connection in a new window or tab. I prefer iTerm2 instead of the default terminal for everything on my mac

Hello everyone!

I have looked at the code of the finetune method and I have a question:

Why is it a better choice to pop the last layer of the network in order to replace it with our own one instead of appending a new layer after the vgg16 layers ?

It seemed like a good idea to me as the last layer of vgg16 outputs (among other things) probabilities of belonging to subclasses of what we are interested in.

PS: thanks a lot to @jeremy and @rachel for the huge amount of work that this MOOC represents.

1 Like

I’m having trouble when executing Vgg16()


NotImplementedError Traceback (most recent call last)
in ()
----> 1 vgg = Vgg16()
2 # Grab a few images at a time for training and validation.
3 # NB: They must be in subdirectories named based on their category
4 batches = vgg.get_batches(path+‘train’, batch_size=batch_size)
5 val_batches = vgg.get_batches(path+‘valid’, batch_size=batch_size*2)

/home/mclasson/nbs/vgg16.pyc in init(self, size, include_top)
31 def init(self, size=(224,224), include_top=True):
32 self.FILE_PATH = ‘http://www.platform.ai/models/
—> 33 self.create(size, include_top)
34 self.get_classes()
35

/home/mclasson/nbs/vgg16.pyc in create(self, size, include_top)
70
71 model = self.model = Sequential()
—> 72 model.add(Lambda(vgg_preprocess, input_shape=(3,)+size))
73
74 self.ConvBlock(2, 64)

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/models.pyc in add(self, layer)
278 else:
279 input_dtype = None
–> 280 layer.create_input_layer(batch_input_shape, input_dtype)
281
282 if len(layer.inbound_nodes) != 1:

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in create_input_layer(self, batch_input_shape, input_dtype, name)
368 # and create the node connecting the current layer
369 # to the input layer we just created.
–> 370 self(x)
371
372 def assert_input_compatibility(self, input):

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in call(self, x, mask)
512 if inbound_layers:
513 # this will call layer.build() if necessary
–> 514 self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
515 input_added = True
516

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in add_inbound_node(self, inbound_layers, node_indices, tensor_indices)
570 # creating the node automatically updates self.inbound_nodes
571 # as well as outbound_nodes on inbound layers.
–> 572 Node.create_node(self, inbound_layers, node_indices, tensor_indices)
573
574 def get_output_shape_for(self, input_shape):

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in create_node(cls, outbound_layer, inbound_layers, node_indices, tensor_indices)
147
148 if len(input_tensors) == 1:
–> 149 output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
150 output_masks = to_list(outbound_layer.compute_mask(input_tensors[0], input_masks[0]))
151 # TODO: try to auto-infer shape if exception is raised by get_output_shape_for

/home/mclasson/anaconda2/lib/python2.7/site-packages/keras/layers/core.pyc in call(self, x, mask)
554 if ‘mask’ in arg_spec.args:
555 arguments[‘mask’] = mask
–> 556 return self.function(x, **arguments)
557
558 def get_config(self):

/home/mclasson/nbs/vgg16.pyc in vgg_preprocess(x)
22 def vgg_preprocess(x):
23 x = x - vgg_mean
—> 24 return x[:, ::-1] # reverse axis rgb->bgr
25
26

/home/mclasson/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.pyc in _SliceHelper(tensor, slice_spec)
305 if s.step not in (None, 1):
306 raise NotImplementedError(
–> 307 “Steps other than 1 are not currently supported”)
308 start = s.start if s.start is not None else 0
309 if start < 0:

NotImplementedError: Steps other than 1 are not currently supported

Hi, within vgg16.py there is a import command
import bcolz. which I don’t have installed.
I tried to install through pip (python package install) but I got error. There is not much information available in the internet about this package either. I am using anaconda latest edition with python 2.7. Please provide me any guidance, thanks in advance.

Thanks @ormkel, I tried open two terminals and they are using the same instance ID and same public IP, so the two terminals should not cause any problem I think.

Thanks again for your help

Daniel

Hi Melissa,

Thanks for this wonderful summary of lesson 1. My question is about how to write the predict() from scatch if this is what you mean in the quote above.

What I have done:
0. I have get kaggle cats and dogs dataset structured, finetuned, and fitted with vgg16.

  1. I have watch the lesson 1 video twice and read the script of vgg.predict().
  2. I noticed vgg.predict( ) needs input img from get_batch()
  3. as the notebook suggest "As large as you can, but no larger than 64 is recommended. ", if I set batch_size = 64, get_batch() and next() together can only returns 64 images at a time.
  4. the with vgg.predict(), 64 images can be predicted.

My question:

  1. How to predict all of the test dataset altogether?
  2. Is writing such a new prediction function is exactly what students are tested for?
  3. I can write some simple python function, but still consider myself to be a beginner. How should I working on it? could you give some hint on writing this function?

Thanks

Daniel

2 Likes

http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/collapsible_headings/readme.html

1 Like

Because you don’t need to backprop during validation, so you can use a larger batch size (which is faster).

2 Likes

The ‘models’ directory in the project data directory is where I save model files that are created in the notebook. However the VGG class downloads the weights for VGG automatically and caches them using keras - which puts them in ~/.keras/models by default. You shouldn’t need to download them or put them there yourself - it should be automatic.

Lesson 2 will teach you this! :slight_smile: