5.0 / 5
We will cover the following tasks in 44 minutes:
In this task I am going to show you what we’re going to do in this tutorial. I will show you the random images we’re going to use as our dataset, I’ll explain how the Rhyme Interface works and finish telling you a little bit about me.
In this short task, we are going to have to do a little grunt work by creating a vector of names. This will help us in the following tasks by allowing us to pull in the images into R using a simple
I will show you how to upload the images into R using EBImage using a
for loop. If you haven’t used a
for loop before, no worries - I will explain what it is the loop is doing while we go through it. If you want to learn more about it don’t stop the video. Wait until after and do a google search - you can learn the for loop in 30 minutes.
The images that I pulled down from the Internet are all images of different sizes. However, our Neural Network model will expect training examples of the same exact shape. Therefore, we will need to resize the images so that they are all of the same shape. We will use a resize function in EBImage to complete this.
Reshaping Data for Neural Network
From this task onwards, we will be performing a basic Neural Network protocol. In this lesson we will be using the array_reshape function which allows us to reshape a multi dimensional array that will allow us to input the data into the Neural Network.
Creating Training Set
As you are probably aware when doing a Machine Learning problem or in this case a Neural Network we need to create the model using a training set. We then test our model on a testing set to see how well it performs. In our case we only have 12 images so we need to figure out how we’re going to set this up. Come on in and we’ll work through this.
Creating Test Set
In this task, we will be build out the test set. Again, since we’re only dealing with 12 images we will only have one image of an airplane and one image of a car in our test set. This will work, but is not ideal. Generally, you will want a much bigger training and test set. The purpose of this project is to show you how to create and train a Neural Networks from scratch using a custom dataset and not one of the pre-processed datasets which come packaged with deep learning libraries.
Creating Labels and One Hot Encoding
We need to set up our labels in this chapter. We will use categorical variables; say 0 and 1. 0 will represent absence of a class and 1 will represent presence of a class. We do this so that we can pass the images through the network and it will know whether it’s a plane or an automobile at the end of the network based on the output. The first index of the label vector represents the class Aeroplane and the second index represents the class Car.
Neural Network Framework
We will build the Neural Network architecture in this task. Our Neural Network will have just one hidden layer. We will be using
relu activations on the hidden layer and
softmax activations on the output layer. The
softmax activation is a natural choice where we want probability distribution across our classes as our output. Once you get familiar with this terminology, building Neural Networks becomes easier. It takes a couple of models though before you get there. So be patient with yourself.
Training the Model
This is the moment of truth! In this task, we will be training our Neural Network model on the dataset. Since we have a very small dataset, it may take a few tries before the model actually catches on the relevant features of our images that help it classify the images properly.
Testing the Model
In this task, we are testing the model’s performance. Remember that we’re using a very small test set. But when we trained the model, we saw that it did very well. So it is likely to do well on a larger test set as well. In any event, this project is to show you how to set the problem up. You can make your models as big as you want or as small as the one we are creating today. You can use much larger training and test sets as well.
How Does Model Perform on New Images?
In this task, we’re going to test our model on images the model hasn’t seen. I happen to know that it works out pretty good. But I’ll show you how to get there. We will then do a quick overview of the journey we’ve taken and after that conclude!
About the Host (Chris Shockley)
I am an R enthusiast, hiker, and amateur astronomer. My favorite hike is located in Mt. Rainier National Park, my favorite Deep Sky Object is Alberio, and my favorite R package is dplyr (since I use it everyday). I have a dog named Coog (Lllasa Apso)., I work as a Data Analyst/Financial Analyst for a Metals Co. located in Seattle, WA. I have been in my current position for 5 years. I work in SQL, R, R Shiny, QGIS. Because I have traveled the roads you are on I believe I will be an asset and will add value to your programming repertoire. We will walk through multiple examples and get to know each other through the process. Don't take my word for it though. Come on in and take a Project or two. Regards, Chris Shockley