Cat Vs Dogs

BK’s Machine Learning / AI World – 1

LOL it’s not easy to keep up to the promise of having 1 blog post per week.. but here I am, trying to keep up my promise!

So I started course about 2-3 weeks ago. Have completed 2 lessons so far, where it jump straight into using Keras with Theano backend and implement a convolutional neural network, to recognize images based on your training data. Wow such a huge aspiration, for me at least.

Nonetheless, the first video is mainly about setting up the environment using AWS P2 instance. I think the cost is like $0.9 per hour where you get to use an EC2 instance with 1 GPU. I am a cheapo.. so I looked for an alternative which allows me to run 100 hours worth of job when I first signed up in FloydHub. Takes me a while to navigate and set it up, but finally got it working (and I don’t need to pay! yay!)

Based on my understanding, how FloydHub works is that you can sync your local files to a running GPU instance, then run your model over there in the instance. Code below shows some example to run a Jupyter notebook with Python 2 + Theano in the GPU instance (after you have created an account in FloydHub).

The –data flag is something that is interesting here. If your dataset is too big, you need to upload your dataset separately to Floydhub first, where you will get a data ID from the output, which then you can feed it to the –data flag above. After which, you can access the data in the /input directory in the GPU instance. More information about how to upload the data here. Alternatively, I think FloydHub have some readily available datasets (such as the first assignment cats vs dogs datasets) which you can access it using the data flag as well.

Thanks for the following 2 reference links as well that helps me get started with FloydHub

Running course notebook on Floyd (Floydhub)


Lesson 1 and 2 of is teaching us how to use the Vgg16 model to recognize cats and dogs image. Apparently once you setup your data sets in proper directory, 7 lines of codes (with the used of readily available Vgg16 model and utils function provided by is enough to recognize cats and dogs up to 97% accuracy! That’s pretty amazing. And from what I heard, we can reuse that piece of code to recognize any other images, and it could be more than 2 categories.

So the directory structure is something like below:

and the code for training and perform validation…

and finally testing:


And we got our classifier for cats and dogs !

This is quite a rusty post, I am sorry if you are reading lol! To be honest I am still figuring out what happen behind the scene, so that I can provide more context in the future instead of just putting codes here. It’s also better for my own personal learning. Will definitely write a better one next time!




Leave a Reply

Your email address will not be published. Required fields are marked *