-: 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 neural network can be applied
and we're actually gonna 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 our property and 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.
Sound 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 four parameters about the property.
We have area in squared feet.
We have the number of bedrooms, the distance,
the city in miles, the near city
and the age of the property.
And all of those four are going to comprise our input layer.
Now, of course there're probably way more parameters
that define the price or property,
but for simplicity's sake we're going to look
at just these four.
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 these input variables would do
is they would just be weighted up by the synapses
and then the output there would be calculated
or basically the price would be calculated
and would get a price.
And for instance, the price could be calculated as 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,
we could use any of the excavation functions
we had previously, you could use a logistic regression,
you could use a squared function.
You could use pretty much anything here.
But the point is that you get a certain output.
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 weights, 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 neural networks
are that even without the hidden layers,
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're plugging 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.
This is gonna be exciting, all right.
We've got all four variables on the left
and we're going to first start with the top neural
on the hidden layer.
Now, as we previously saw in the previous tutorials,
all of the neurals from the input layer,
they have synopsis connecting each one
of them to the top neural in the hidden layer.
And those synopsis 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 important
for every single neural.
Sometimes inputs will not be important.
And here we can see two examples that X1, X3,
the area and the distance to the city in miles are important
for that neural whereas bedrooms and age are not.
And let's think about this for a second.
How would that be the case?
Like why would a certain neural be linked
to the area and the distance?
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 makes sense.
And probably what this neural is doing is it
is looking specifically, it's like like a sniper,
it's looking for area properties which are not
so far from the city, but have a large area.
So for their distance from the city,
they have an unfair square foot area, right?
So something that's abnormal.
It's 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.
Again, we're speculating here,
but that neural might be picking out laser picking
out those specific properties and it will activate,
hence the activation function.
It'll activate, it'll fire up only when the certain criteria
is met that you know the distance and the area
of the property, distance to city
and the area of the property.
And it performs its own calculations inside itself
and it combines those two and as soon
as certain criteria, it fires up and that contributes
to the price in the output layer.
And therefore this neural 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 neurals
and we'll see just now how the other ones work.
But what I wanted to agree here
is that let's not even draw these lines
for the synopsis that are not in play
so that we don't clutter up our image.
That's the only reason we're not gonna draw them.
So let's just get rid of those two
and that way we will know exactly, okay, so this neural
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 neural.
So we've got the area, the bedrooms
and the age of the property.
So what could be the reason here?
Again, let's try to understand the intuition,
the thinking of this neural.
How is this neural thinking?
Why is it picking these three parameters?
What could it be?
What could have hit like found in the data, right?
So we've already established this is a trained up data set.
The training has happened a long time ago,
maybe like a day ago or somebody's already trained
up this data.
So now we're just applying and we know that this neural
through all 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 has 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 which are new, right?
Which are not old properties.
Because maybe in that area, most of the properties are kind
of like big properties are usually old,
but there's lots of modern families
and maybe there has been a social demographic shift
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 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 with
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 a high area
and lots of bedrooms that is valued.
In that market, that is valuable.
So that neural has picked that up.
It knows that, okay, so this is what I'm gonna
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.
As soon as that criteria is met, the neural fires up.
And the combination of these three 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 attribute that helps with the evaluation
of the property.
It combines them into a new attribute
and therefore it's more precise.
So there we go, that's how that neural works.
And let's look at another one.
Let's look at the very bottom one.
For instance, this neural could even have picked up
just one parameter.
It could have just picked up age
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 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 especially
in the higher socioeconomic classes,
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 neural 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 the rectifier
function being applied.
So here you've got like a zero until a certain point,
let's say 100 years old and then after 100 years old,
the older it gets the higher the contribution
of this neural to the overall price.
And it's just a very simple example
of this rectifier function in action.
So there we go.
That could be this neural.
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 the city,
maybe that's in combination somehow contributes
to the price.
Maybe it's not as strong as the other neurals
and it contributes, but it still contributes.
Or maybe it detracts from the price.
That could also be the case or other things like that.
And maybe a neural picked up a combination
of all four of these parameters.
And as you can see that these neurals,
this whole hidden layer situation allows you
to increase the flexibility of your neural network
and 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 in anthill,
but when you have like a thousand
or a hundred thousand ants, they can build
an anthill together, right?
And that's the situation here.
Each one of these neurals by itself cannot predict
the price, but together they have superpowers
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 in understanding how to utilize them.
There we go.
So that is a step by step example and walk through
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.