All right.
Exciting tutorial ahead.
Welcome back to the course on Deep Learning.
Today we're talking about how do neural networks work.
Now we've laid a lot of groundwork.
We've talked about how neural networks are structured.
What elements they consist of and even their functionality.
And today
we're going to look at a real example of how a new neural network can be applied.
And we're actually going to work
step by step through the process of its application.
So we know what's going on.
So let's have a look what example we're going to be talking about.
We're going to be looking at property valuation.
So we're going to look at a neural network
that takes in some parameters of a property and values values it.
And the thing here, there's a small caveat for today's tutorial.
And that is we're not actually going to train the network.
So a very important part in neural networks is training them up.
And we're going to look at that in the next tutorials in this section.
For now we're going to focus on the actual application.
So we're going to work with a neural network that we're going to
pretend is already trained up.
And that will allow us to focus on the application
side of things and not get bogged down in the training aspect.
And then we'll cover off the training when we already know the end goal.
We're working towards some good.
All right. Let's jump straight into it.
So, let's say we have some input parameters, right?
So let's say we have full parameters about the property.
We have area in square feet.
We have the number of bedrooms, the distance, the city in miles.
the nearest city and the age of the property.
And all of those four are going to comprise our input layer.
Now, of course, there
probably way more parameters that define, the price of a property.
But for simplicity's sake, we're going to look at just these for now.
In its very basic form, a neural network only has an input layer
and an output layer.
So no hidden layers.
And our output layer is the price that we're predicting.
So in this form what's these input variables would do is
they would just be weighted up, by the synapses.
And then the output layer would be calculated.
Basically the price would be calculated and we'd get a price.
And for instance, the price could be calculated as a simple
as, the weighted sum of all of the inputs.
And again here you could use pretty much any function.
You could use, what we're using now, you could use
any of the activation functions we had previously.
You could use a logistic regression.
You could use a squared function.
You could do pretty much anything here.
but the point is that you get a certain output and, and moreover,
most of the machine learning algorithms that,
exist can be represented in this format.
This is basically a diagrammatic representation of how you deal with the,
the variables.
Right, by changing the way it's the formulas, you can accomplish
quite a lot of the, machine learning algorithms that we've talked
about before and put them into this form.
And that just stands to show how powerful new neural networks are, that even
without the hidden layers, we already we already have
a representation that works for most other machine learning algorithms.
But in neural networks, what we do have is an extra advantage that gives us lots
of flexibility and power, which is where that increase in accuracy comes from.
And that power is the hidden layers.
And, there we go. That's our hidden layer.
We've added it in, and now we're going to understand
how that hidden layer gives us that extra power.
And in fact, to do that, we're going to walk through an example.
So as we agreed, this neural network has already been trained up.
And now we're just going to plug in.
We're going to imagine
that we plug in a property and we're going to walk step by step,
through how the neural network will deal with the input
variables and calculate the hidden layer and then calculate the output layer.
So let's go through.
This is going to be exciting.
All right.
We've got all four variables on the left.
and we're going to first start with the top neuron on the hidden layer.
Now as we previously saw in the previous tutorial, all of the
neurons from the input layer, they have synapses connecting it
to each one of them to the top neuron in the hidden layer.
And those synapsis have weights.
Now let's agree that some weights will have a non-zero value.
Some weights will have a zero value, because basically not all
inputs will be valid or not.
All inputs will be important for every single neuron.
Sometimes inputs will not be important.
And here we can see two examples that x one and x three.
The area and the distance to the city and miles are important for that neuron,
whereas bedrooms on edge are not like.
And let's think about this for a second. Why?
How would that be the case?
Like why would a neuron, be linked to the area and the distance?
What does that what could that mean?
Well, that could mean that, normally the further away you get from the city,
the cheaper real estate becomes, and therefore the space
in square feet of properties becomes larger. Right?
So for the same price, you can get a larger property
the further away you go from the city. That's normal. Right.
That that makes sense.
And probably what this neuron is doing is it is looking specifically
it's like like a sniper.
It's looking for area properties which have
which are not so far from the city but have a large area.
So for their distance from the city, they have an unfair, squared foot area.
Right. So something that's abnormal is is higher than average.
So they're quite close to the city,
but they're still large as opposed to the other ones at the same distance.
And so that neuron again we're speculating here, but that neuron
might be picking out laser, picking out those specific properties.
And it will activate.
And hence the activation function, it will activate.
It'll fire up
only when the certain criteria is met that you know, the distance and that,
area of the distance, the city and the area of the area of the property.
And it performs its own calculations inside itself.
and it combines those two.
And as soon as certain criteria is made, it fires up.
And that contributes to the price in the output layer.
And therefore this neuron doesn't
really care about bedrooms and age of the property
because it's focused on that specific thing.
That's where the power of the neural network comes from,
because you have many of these neurons.
And we'll see just now how the other ones work.
So but what I wanted to agree here is that let's not even draw these lines
for the synopses that are not, in place so that we don't clutter up our image.
That's the only reason we're not going to draw them.
So let's just get rid of those two.
And that way we will know exactly okay.
So this neuron is focused on area and distance to the city.
All right.
So as long as we agree on that let's move on to the next one.
Let's take the one in the middle here we've got three parameters
feeding into this neuron.
So we've got the area the bedrooms and the age of the property.
So what could be the reason here.
Let's again let's try to understand the intuition
that the thinking of this neuron.
How is this neuron thinking.
Why is it picking these three parameters. What could it be.
What could have a hit like found in the data.
Right. So we've already established this a trained up data set.
The training has happened a long time ago.
Maybe like a day ago or somebody is already trained up the data.
So now we're just applying.
And we know that this neuron, through all of the thousands of examples
of properties, has found out that the area plus
the bedrooms, plus the age combination of those parameters is important.
Why could that be the case?
Well, for instance, maybe in that specific city,
in those suburbs that this neural network had been trained up in,
perhaps, there's a lot of families,
with kids with two or more children who are looking for,
large properties with lots of bedrooms, but which are new, right.
Which are, not old properties, because maybe in that's in that area,
all most of the properties are kind of
like big properties are usually old, but there's lots of modern families.
And yeah, maybe there was has been a social demographic shift.
And or maybe there's been like a lot of,
like some growth in terms of employment and jobs
for the younger side of population, maybe just, you know, the
like the population demographics have changed.
And now, younger, couples or younger
families are looking for properties, but they prefer newer properties.
So they want the age of the property to be lower.
And hence from the training that this neural network has undergone,
it knows that when there's a property with a large, area
and with lots of bedrooms, at least
at least three bedrooms for the parents, for the first child, for the second child,
for at least three bedrooms, maybe a guest room.
when a new property with, high area
and lots of bedrooms that is valued that in that market that is valuable.
So that neuron has picked that up.
It knows that okay.
So this is what I'm going to be looking for.
I don't care about the distance to the city in miles, wherever it is,
as long as it has high area, lots of bedrooms.
And as soon as that criteria is met, the neuron fires up and the combination
of these two parameters
and this is again, this is where the power of the neural network is coming from,
because it combines these three parameters into,
a brand new parameter into a brand new attribute that helps
with the, evaluation, with the helps with the valuation of the property.
It combines them into a new attribute and therefore it's more precise.
So there we go. That's how that neuron works.
And let's look at another one.
Let's look at the very bottom one.
For instance, this neuron could be could even have picked up just one parameter.
It could have just picked up H and not any of the other ones.
And how could that be the case?
Well, this is a classic example of when age could mean like.
As we all know, the older property is usually it's less valuable
because it's worn out.
Probably the building is old, probably,
you know, things are falling apart, more maintenance is required.
So the price drops in terms of the price of the real estate,
whereas a brand new building, it would be more expensive because it's brand new.
But perhaps if a property is over a certain age,
that could indicate that it's a historic property.
For instance, if a property is under 100 years old, then
the older it is, the less valuable it is.
But as soon as it
jumps over 100 years old, all of a sudden it becomes a historic property because,
this is a property where people used to live hundreds of years ago.
It tells a story.
It's got all this history behind it.
And some people like that. Some people value that.
In fact,
quite a lot of people would like that and would be proud to live in a property.
And, especially in the higher socioeconomic classes, they would
they would show off to their friends or things like that.
And therefore, properties that are over 100 years old could be deemed as historic.
And therefore this neuron, as soon as it sees a property
over 100 years old, it'll fire up and contribute to the overall price.
And otherwise, if it's under 100 years old, then it won't even work.
And this is a good example of, that, the, rectifier function being applied.
So here you've got, like a very, like a zero
until a certain point and then let's say 100 years old
and then after 100 years old, the older it gets, the higher the
the higher the contribution of this neuron to the overall price.
And that's just a wonderful example of,
very simple example of this rectifier function in action.
So there we go. That could be this neuron.
And moreover, the neural network could have even picked up
things that we wouldn't have thought of ourselves.
Right.
For instance, bedrooms plus distance to city
maybe that's in combination somehow contributes to the price.
Maybe it's not as strong as the other neurons
and it contributes, but it's still contributes.
Or maybe it detracts from the price.
So it could also be the case or other things like that.
And maybe a neuron picked up all four,
a combination of all four of these parameters.
And as you can see, the, that these neurons,
this whole hidden layer situation allows you to increase
the flexibility of your neural network and allows you
to really allows the neural network to look for very specific things.
And then in combination, that's where the power comes, from.
It's like that example of the ants, right?
Like an ant by itself cannot build an ant hill.
But when you have like 1000 or 100,000 ads, they can build an anthill together.
Right? And that's that's the situation here.
Each one of these neurons by itself cannot predict the price.
But together they have super powers and they predict, the price
and they can do quite an accurate job if trained properly, if set up properly.
And that's what this whole course is about,
and understanding how to utilize them.
There we go.
So that is a step by step example
and walkthrough of how neural networks actually work.
I hope you enjoyed today's tutorial and I can't wait to see you next time.
Until then, enjoy deep learning.