Hello, everyone.
Welcome back.
In this lecture, we are going to learn about two Quantum's.
One is how to be a neural network for regulation problems.
And the second is how to do it using functional EPA.
Now, we have been using sequential EPA and distractibility.
How to use functional EPA functionally is basically used for defining complex models such as multi input
or multi output models or models which have shared Lyd.
So first, really make the normal model using functional EPA, which could also be done using sequentially.
But then we will create a complex neural network structure which can only be handled by a functional
EPA.
Also, we'll be solving a problem, which means our output variable is a continuous measurement.
That is, it is not due to one pipe.
It can have any value without any boundaries.
This problem we'll be using Boston housing data.
It it is a very standard data set in which we have 14 variables.
Thirteen of the productivity bills and 14th one is the value of the House, basically using the values
of 13.
Productivity was we want to predict the value of health.
This is also an in big data, it may not get us, Labidi, but we got important using this line.
If you want to know more about the Boston housing data set, you can visit this link.
It has details of all the 13 predictor variables.
The predicted variables include variables like crime rate, number of hotel rooms and Tequilla.
You can see that Boston housing Natus is now imported.
You can look at this by clicking on it.
The Boston housing dataset has two parts brain part and the best part within brain.
We have 404 observations of 13 predictive variables.
That is in the X and we have the labels.
That is the value of hosting.
We predicted invite in test.
We have a set of one hundred two observations.
Again, taking predictive valuables and invite.
We have the opportunity to.
Now, as we did earlier, we'll be importing the training part into train data and train levels, variable
and testing part of this dataset into best data and best labels.
The next event, these two lines of code.
And now we have these new labels, test data and brain data.
These are the predictor part of the data.
And best labels and brain labels, these are the upper part of the victim.
Next, guns preparing the data.
And one of the important steps that we saw earlier was normalizing the data in the previous problem.
We had only pixel data, which was homogeneous.
So we simply divided it by two to five to get the skilled version of that data.
But now we have heterogeneous data that is all these 13 variables representing 13 different things.
It is not easy to scale such kind of data
to normalize this data.
We use this function sked.
This scale function automatically finds out the mean of every variable and the standard deviation of
everybody.
And it uses that formula that I showed you earlier.
It's a prakriti mean from each value.
And divides that value by the standard deviation.
So simply using the scale function, you can normalize our training data to normalize the data.
We do not use the mean and standard deviation of Vitez data.
We used to mean standard deviation of deigning data.
The concept is Maeno only deplaning part of the data.
Our model does not know any other detail of the word.
We have only the training, but from that we find out the mean and standard deviation of each variable.
We assume that this standard deviation and mean of each variable applies to the entire dataset of the
world.
So using those mean and standard deviations, we will be scaling up test data.
Also.
So in this light, we will scale our training data using descale scale function and this line we will
find out deep Collum means indicating data and we'll be storing that information in this variable called
Mean Street.
In this line, we are finding out the standard deviation of these variables and training data and storing
them individual court call standards.
Now using the means of training data and standard deviations.
We use the scale function.
It is the same scale function.
But here we are specifying the mean and the standard deviation to be used for scaling this test data.
Now our data is ready.
Our trained data is not released.
Our test data is also normalized.
Any new data on which you want to predict the outcome of the model?
You have to scale it again.
Using this scale function.
Now comes the part when we define neural network.
This time we'll be using functionally be a functionally B.A. has two different parts.
One is the input and one is output input with early model about all the variables that we are inputting
in the model.
So basically in the input layer, we build the model that we have a input layer off shape is equal to
number of variables.
I could have written 13 here because I know that the number of variables are 13 in this particular dataset.
But even if you change your train data, you'd need not update your model.
If you divided like this, if you write this way, this means that you want to get this second dimension
of the training data.
So basically training data has these two dimensions.
It has 400 photos and 13 columns.
We want this dimension because this represents the number of believers in this training data.
So that is why we have we have written to here.
So using this, even if you change your train data to any other dataset, you'd need not a baby or ship
for this neural network.
It will automatically get updated.
The second part is the output layer and this layer.
We first include the input layer to this output layer, which is the same as the input layer that we
created earlier.
This is important because this creates the connection between the input layer and output.
If we do not specify that this output layer has this input layer, then there would be no connection
between these two.
So in the output layer, the first thing is always the input layer that it will take.
Then comes the hidden lives, which is similar to the way that we specify in these sequential EPA.
In this scenario, we are using two layers, both with 64 neurons.
The activation function for both of these is really.
Lastly, that is the output layer has only one neuron and it has no activation function because it is
a regression problem.
So let's run these two lines of code.
This creates one input into inputs.
Now, this will create another out preventer, which is predictions.
Nine functionally.
We create the model using Gaydos model function.
It takes two parameters.
One is the inputs and one is output inputs.
We have named as inputs only and the outputs has been named as predictions.
So in particular, input output is equal to predictions.
And this defines the models architecture.
So our models architecture is we have 13 variables which are coming in as input in the first 10 led.
We have 64 neurons in the second layer.
We have another 64 neurons.
And in the output layer we have one output neuron.
So when I've done this, a model is created and it's architected is specified.
Now we configured this model in configuration.
We specify the optimize it.
We can use a duty Artemus prop or whichever you like.
Lost function for immigration problems is a messy means squared.
A matrix is not a necessity.
However, we have used mean absolute error
to win and underscore modellers configured.
Now we bring in our model using the fit function.
Again, we input training, data, training levels, epochs and deep Betsey's.
You can see that the mortar is landing for the epochs and loss.
That is the embassy is steadily closing.
I mean, to do that, it is also because the model has run on the box.
We can check the performance of this model on our desk.
This is similar to what we have done when we were using sequentially.
B, you d evaluate function and importantly tested them best labeled and do it do list on the test loss
and test absolute error.
We can run these two commands and we can see that the test loss is Tuqay two point five six.
And this absolute error is four point four.
So in this video we saw how to use functionally be to build another model.
This model could have been built using sequential EPA as well.
And in fact, it would have been easier to use sequentially pay it.
But in the next lecture, you can see if we have a complex neural network architecture, how functionally
they helps us in building that scene in the next one.