Recently I was following a machine learning Tutorial and even that ML requires a strong background in math, I am still fascinated with this domain and I want to advance more in this field. Yesterday I was following the part of Deep learning and how to make an Artificial Neural Networks (ANN) or Convolutional Neural Networks (CNN) and in one word deep learning is awesome!
It was the first time I was up late trying to finish this tutorial part.
Today, I implemented the CNN and I spent the whole day trying to make TensorFlow work on the GPU.
What I did was writing a basic script, I made a model that trains using images of cats and dogs and afterward in the test set it will tell you if the image has a cat or a dog.
The machine learning model is a classification between dogs and cats, this could be used with any other images like birds or cars or anything I just have to change the data set.
I followed a tutorial, it's not something I did on my own and I am not going to say I understood what the script does 100%.
Few things are still complicated for me, but I am planning to understand them more and after I finish the whole tutorial I am planning to focus more in the deep learning field, it looks like an amazing field.
Deep learning need more Compute power, and it's better to use the GPU over the CPU, for my case after I spent the whole day trying to make Tensorflow work over the GPU I even made a post about it: Make Tensorflow use the GPU, I find out that my graphics card is old 😞. so for the moment, I am going to keep working with the CPU.
Let's talk a little about the script :
To make the CNN I used Keras lib that uses Tensorflow in the back end, the reason for using keras and not Tensorflow directly is that Keras make things easy and I will write less code. By the way, Keras was made by a Google developer member.
The tutorial I followed was a little old and by old, I mean less than a year old but the deep learning is a new field the libraries and packages do get new updates frequently. So to follow the tutorial I had to change few things and thanks to google and the documentation I was able to see the new changes.
I got 0.9958 accuracy for the train set and 0.7705 for the test set (difference 22%) which is kinda good, it means from 4 images the model is able to identify 3 correct images and this could be improved by adding other layers or add more images to the train set. Keras website has 25k images of dogs and cats (500mo), to follow this tutorial I only used 10k, also there are few parameters that could be changed to improve the result but this will need to train the model all over again, people were able to get 0.98914 accuracies using other lib and this was achieved 4 years ago so yeah deep learning is awesome!
In the tutorial, the instructor got 0.8452 accuracy for the train set and 0.7510 for the test set (difference 10%) and when he added a new layer the result got improved by 0.8516 accuracy for the train set and 0.8180 for the test set (difference 3%)
I left the pc open for 9 hours to get the result xD the CPU was working to the full performance for the whole night.
I am not going to add another layer and wait another 9 hours to compare the result x)
Anyway, I uploaded the script to GitHub, it also have the data set, 10000 images of cats and dogs about 230mo.
Link: https://github.com/HosniMansour/machine-learning-cnn-cat-or-dog
0 comments:
Post a Comment