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
Coming into this project I had 0 experience with Neural networks. I was completely lost — “train iterator”, “activation function”, what did these words even mean?
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.
The model I built wasn’t working. I had gotten a diagnosis of 96% accuracy, yet when it came to actual usage it did no better than a coin toss. This (which I would later realize) was a byproduct of overfitting and logical issues within my code.
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.
I wouldn’t be telling this story if I just ended like that. Using the skills I inadvertently learned from building my first model I put all my effort into a second model.
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.
Dummy check your code. Throughout this process, I spent hours on code that could’ve been solved in just minutes. With neural networks, logic errors will show up way more than syntax errors. Before you stack overflow it, re-read your code to make sure everything is exactly as you want it.
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.
Binary Keras CNN. Contribute to EdWangward/khclassifier development by creating an account on GitHub.
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.