How does Neural Network Work? A step by step Guide.

teacher, brain, brain research

Do you wanna know How does Neural Network Work? if yes, then give your few minutes to this article. This article is going to be very interesting for you along with that you will understand how neural network works.

Hello, & Welcome!

In this blog, I am gonna tell you-

  1. How does Neural Network Work with Example?

I have discussed with you about Deep Learning, Neuron in Artificial Neural Network, and The Activation Function so far. Now its time to teach you how does the neural network work?

So without wasting your time, let’s get started-

How does Neural Network Work with Example?

I will explain to you with the help of an example so that you will understand the whole working of neural networks very easily. So I am going to take an example of property evaluation. So in the full article, you are going to look at a neural network that takes some parameters of the property and values.

Neural network example

In that property evaluation example, there is a house. And in that example or article, we are not going to train the network. Traning is a very important part of neural network which I will discuss in the next article. But as of now just we will see the application of neural network how it works practically. Here we are pretending that the neural network is already trained.

Got it! Now let’s move into it.

Suppose we have four input parameters-

  1. Area ( in square feet).
  2. Number of Bedrooms.
  3. Distance to City (in miles).
  4. Age of the property.

So our input layer is comprised of these four input parameters. There may be more parameters but just for simplicity, I am going to take only four parameters.

Basic Neural Network-

The basic neural network only has two layers the input layer and the output layer and no hidden layer. In that case, the output layer is the price of the house that we have to predict. So the basic neural network looks something like that-

How does Neural Network Work

So in the basic neural network, these input variables are just weighted up with synapses and the output is calculated. In that case, we get an output as a price. And here you can use any activation function in the output layer for predicting the output.

How does Neural Network Work

Without having a hidden layer neural networks perform most of the operations. So this shows how much a powerful neural network is.

Standard Neural Network-

In the neural network, we have the flexibility and power to increase accuracy. And that power is a hidden layer. And with hidden layer, the neural network looks something like that-

Neural Network

Now we are going to understand How that hidden layer gives us extra power. As I have told you that we will understand with the example of property evaluation. So now we are going to walk step by step through how the neural network deals with input variables and calculate the hidden layer and then the output layer.

So, let’s go through and its gonna be exciting for you.

As in the picture we have four variables in input layer on left. And we are going to start with the top neuron on the hidden layer.

Case 1-

As I have discussed in previous articles that neurons are connected with the help of synapses. And these synapses have some weights. Some weights may have zero value and some weights may have non zero value. That means not all inputs are valid and important for every single neuron. Sometimes some inputs are not valid for some specific neuron.

So here in the picture, you can see that for the first neuron in hidden layer only two inputs are valid and important. That is Area and Distance to the City. For that neuron Bedroom and Age is not important.

Neural Networks

So, let’s think about this case, where only two parameters are important- area and distance to the city. Do you have question in your mind that What does it mean? So it means that the farther away you get from the city the cheaper real state becomes. And therefore the space or area in square feet of the house becomes larger. So for the same price you get a larger property as farther away you go from the city. That’s normal!.

So what this neuron is doing? It is looking specifically like a sniper. That means it is looking for properties that are not so far from the city but have a large area. So the activation function will activate and it will fire up only when the certain criteria are met. And then this neuron performs calculations inside itself and it combines these two input variables. And that contributes to the price in the output layer.

Therefore this top neuron doesn’t care about bedrooms and age of the property because it is focused on these two parameters.

Now, let’s move on to the next neuron.

Case 2-

Let’s take the middle one neuron. Here we have got three parameters feeding into this neuron. That is area, number of Bedrooms, and Age of the property.

So what is the reason for this case?

Let’s again try to understand the intuition and the thinking of this neuron. Why this neuron is taking these three parameters?

So the reason is that in specific cities neural networks may be trained for those families who have two or more children. And these families are looking for large and new properties with lots of bedrooms. They are not looking for older properties. So they want the age of the property to be lower. When this neuron finds a property with a new, large area and with lots of bedrooms, it will fire up. So neuron picks up this property. and it knows that “OK so this is What I’m going to be looking for”.

So here the power of neural network comes because it combines these three parameters into a brand new parameter or attributes. And that helps with the evaluation of the property.

Case 3-

Let’s look at another neuron, the bottom one. Suppose this neuron picked up only one attribute that is age.

how does neural network work?

So What’s the reason for this case?

Well, this is the classic example of when age can mean. As we all know the older properties are less valuable because they required more maintenance. So the price drops in terms of the price of real estate. Whereas a brand new building is more expensive because its new and no maintenance required.

Perhaps if a property is over a certain age that can indicate that it’s a historic property. For instance if a property is under 100 years old then its less valuable. But as soon as it jumps over 100 years old all of a sudden it becomes a historic property. Because it tells a story and some people like that. In fact, a lot of people feel proud to live in such a property.

Therefore this neuron as soon as it sees a property over 100 years old it will fire up and contribute to the overall price. And if the property is under 100 years old then it will not work. This is the good example of the Rectifier function. So here you have got 0 until a certain point let’s say 100 years and after 100 years old the older the property gets the higher the value. And higher the contribution of this neuron to the overall price.

Final Note-

The neural network could have picked up things that we wouldn’t have thought of ourselves. For instance, they can pick up a bedroom and city maybe that is in combination and somehow contribute to the price. It may be not as strong as other neurons but still, it can contribute.

Or maybe a neuron picks up all four parameters. And as you can see that these neurons and this whole hidden layer situation allow you to increase the flexibility of your neural network. So that’s the power of the neural network.

As a single ant can’t build a colony but a thousand of ants can build. Similarly, a single neuron can’t predict the price but together they have a superpower.

So, that’s all a step by step example and walkthrough of How does Neural Network Work?. I hope you understand. If you have any questions, feel free to ask me in the comment section.

Enjoy Learning!

All the Best!

Read Gradient Descent from here- Gradient Descent- Understand Completely in a Super Easy Way!

Read Stochastic Gradient Descent from here- Stochastic Gradient Descent- A Super Easy Complete Guide!

Thank YOU!

Though of the Day…

It’s what you learn after you know it all that counts.’

John Wooden

Read Deep Learning Basics here-

author image

Written By Aqsa Zafar

Founder of MLTUT, Machine Learning Ph.D. scholar at Dayananda Sagar University. Research on social media depression detection. Create tutorials on ML and data science for diverse applications. Passionate about sharing knowledge through website and social media.

Leave a Comment

Your email address will not be published. Required fields are marked *