Takeaways from building a CNN in Keras

failing my way to 92% accuracy

For the past two weeks, I’ve been working on something special. A Convolutional Neural Network that’s able to distinguish between two human faces. From collecting data to building the model, here’s how I built the model.

Building the first model

The goal was to build a complete CNN yet I couldn’t even get my data assembled. If I wanted to complete this project I needed to learn and fast. So I did things the old reliable way, going through every single line of code I didn’t understand. From importing libraries all the way to prediction, I slowly but surely gained an in-depth understanding of the code.

And finally with some caffeine, youtube tutorials, and a lot of Stackoverflow I was finally able to assemble my model. The feeling was incredible. And so satisfied with my model I decided to see its magic take place. Sitting in front of my screen the model started running I breathed in anticipation as my model — crashed and burned.

Failure

But stubbornly I decided to continue to pursue this model, changing small parameters hoping they would solve this massive issue. Yet it was all pointless this model was beyond salvageable, and ultimately one and a half weeks in I tossed the entire thing away.

Round 2

This time I decided to research more into logic, such as VGG and visualizing all cells carefully to make sure my model was doing what it was supposed to do.

And it paid off.

Within 3 to 4 days I was able to assemble my functioning CNN with an accuracy of 92%. Now that’s a hell of a lot better than a coin toss.

Lessons Learned

Be Lazy. Tasks like data collection SUCKS. Find the laziest (and smartest) way to do it. For my process, I used Birme (bulk image resizing made easy), which literally saved me hours of work. Try to find ways to make your life easier online.

Seek help. This real treasure was the friends I made along the way! Well, not really but they helped a ton. Getting a second pair of eyes, and a new perspective was one of the most helpful things throughout this project.

Results

Video:

This project was one of the most challenging things I’ve done with AI. It was also by far the most valuable. If you want to continue keeping up to date with my new projects click the follow bottom or reach out to me with any of these links below.

Contact me

Linkedin

Artificial Intelligence, Deep learning enthusiast.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store