Ulog: Coding Neural Networks with Python part 2: the Convolutional Neural NetworksteemCreated with Sketch.

in #partiko5 years ago

Today I worked on building a Convolutional Neural Network, and let me tell you, it is quite convoluted.

Convolutional Neural Network

This Convolutional Neural Network will analyze images and determine whether it is an image of a cat or a dog. What makes it convoluted is the way it handles everything. First it takes an image file and compresses it down to a manageable size to reduce the number of pixels. Then it reduces the image further with some sampling and feature mapping. This could be things like detecting pointy ears, pupil shape, nose shape or length, whiskers, or any other feature or detail the AI might pick up on.

It then follows up with what's called pooling, where bits of data are averaged across a grid and again made smaller, even though more numerous.

Then it is flattened. End result of this step is all the values in the grids are stretched out and "flattened" in order to make a single line of data.

Next it is linked to a more simple Neural Network that just analyzes the parsed and optimized data. In this section, it goes through each piece collected and decides whether it's a dog part or a cat part. It then collects all the part decisions and outputs the best answer.

Here is the code to do all that.

The Training

I was given a folder containing 10,000 images for it to use: 8,000 to train and 2,000 to test. Using the last few lines of code, we begin the testing phase.

Pointing to the folder, the app reads all the pictures, then it decides cat or dog. In training, each image comes with the correct answer.

I started this before I left the office. Here's the output before I left for the day:

What this shows is it will process all 8000 training images 25 times, with each round being referred to as an epoch. With each epoch taking about a half hour, it should be just about done. I'll check it out in the morning and tell you how I did.

Posted using Partiko Android

Sort:  

Congratulations @alanman! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Thank you so much for being an awesome Partiko user! We have just given you a free upvote!

The more Partiko Points you have, the more likely you will get a free upvote from us! You can earn 30 Partiko Points for each post made using Partiko, and you can make 10 Points per comment.

One easy way to earn Partiko Point fast is to look at posts under the #introduceyourself tag and welcome new Steem users by commenting under their posts using Partiko!

If you have questions, don't feel hesitant to reach out to us by sending us a Partiko Message, or leaving a comment under our post!

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 98833.06
ETH 3391.57
USDT 1.00
SBD 3.08