Now, let's create the structure of our first artificial neural network model before starting.
Let's just set random seed 242 using these glues statements.
Random seed is used to replicate the same desert every time.
You can use any number instead of 42 if you use that number in future when you are running the same
code.
You will get the same output as we have discussed in the theory.
There are multiple occasions where what neural network generates random number, such as assigning the
initial weights using random seed will help you to reproduce the same result.
Using the same initial weight every time just on this.
So for the weight problem, we have observations in the form of 28 and 220 pixels.
Observations are in the form of two B three.
And as an output, we want ten categories.
These categories are exclusive.
That means a single image can either be a t shirt ordered top or a boot.
This is what we are planning to do.
We are first converting a word to be observations and do a flight when the observations.
So insert over to be array of 28 and 228 pixel.
We want 784 pixel in our input layer.
Then we are going to create two hidden layers.
The activation function, which we are going to use for hidden layers, will be value as discussed in
the theory lecture.
We always prefer RELU for classification models.
And in the output since this 10 categories are exclusive.
And and this is a classification model.
We will be using softmax activation.
We have already discussed this activation types in order to be reelected.
That's why we are not going to discuss it here.
Now let's start creating this neural network using sequential IPS of data.
First, we will need to create and model object.
So our object variable name is model.
And we are just creating it using this function.
Keita's dot models dot sequential.
In this sequential object, we can add different layers.
We will start with our input layer.
We'll move on to then layer one, then to head on layer two.
And then to the output layer.
So first, for the input layer, we can write like this model dot egg.
And then guide us dot layers.
And then since we want to convert this to be array of 28 into 28 pixels to, say, 184 pixel in a single
Larry, we are using flatten.
And then we need to provide the input shape of over X variables, since about X variable is a boody
at age 28 and 28 Viksten.
We are using input chip equal to then we are providing a list of two variables that this friend dear
call my 28.
Then over second layer is the hidden layer.
So in the next step, we are adding another layer that is model dot and then guitars, dot layer.
And since this is a dense layer, will write dense.
And here we need to mention the number of neurons we want in this layer.
So in hidden layer one, we need 300 neurons.
That's why we are writing 300.
And then we want RELU activation function.
That's why we are writing activation equal to Relu in the next step.
We want another hidden layer.
So we are following the same process.
That is, we are writing more than not add.
And in record we are writing Keita's dot layer dot bends.
And in this layer we 100 hundred neurons.
That's why we are writing.
Hundred and then activation equal to Relu since this is also a hidden layer.
We want activation function to be begin in the next output layer.
We want 10 different categories.
That's why we have to add 10 neurons.
And to this layer.
And since the classes are exclusive.
That's why we have to use softmax activation.
So we'll write model, not add.
And then Keita's dot layers, dot bends.
And then the number of neurons, which is span and activation, equate to softmax.
I hope you remember Waterloo and Softmax are relu is zero for all the negative numbers and equate to
the input for all the positive inputs.
Various softmax equates the sum of all the class probability to one
in case if you want any additional aid on land, you can always add additional layer between any of
these layers in the later part of the course.
We will see how to choose the number of neurons in each layer.
Let's run this after creating this model structure.
You can look at it using somebody's method.
So if you write your object name, that is model and if you write dort somebody.
The model, somebody's method displays all the modern layers, including eight layers.
Names its output shape and the number of parameters.
So these are the layer names.
Second is the output shape.
This the number of output.
And this is the bed size of the input.
Since we are passing all our data.
That's why this is none.
None means no limit on input data.
And next is the number of Kreen label parameters, since our imports have 784 variables and we are passing
each of these variables and to 300 different neurons.
We have individual weights for each of these linkages.
So total number of weights is 784 and two 300 plus.
There are other 300 Biase variables that are associated with each of these neurons.
So 784 and two 300 plus 300 will give you this number.
Our neural network is trying to optimize this many parameters for this layer.
Similarly, these are the trainable parameters for this layer.
Again, this will be three hundred and 200.
There are three hundred and two hundred linkages between these two layers.
And each of that linkage will have associated weights and each of the neuron in this layer.
That is, hundred neurons have hundred different Bias's values.
So 300 and 200 plus hundred.
So thirty thousand one hundred trainable parameters are associated with this layer.
Similarly, 1010 trainable parameters are associated with this layer.
So at the bottom, you get the summary of total number of trainable parameters.
And this neural network.
So our neural network will try to optimize this many parameters to get the best result.
Now, if you want to look at the world now, if you want to look at our neural network, you can do
that using Bidart.
So you have to import Bidart.
And if Bidart is not installed in your system, you can install it using PIP space, install space Bidart
or KONDA Space, install space Bidart in your command prompt.
So if you just redgate us not utilities, dot plot, underscore model and then give your object name.
And if you run this, you will get the structure of fewer neural network.
So here we have input layer.
Then we have lightning that budy array and A one B array.
So that's why we have a flatten layer.
And then we have too dense who'd been led.
And we have an output layer which is giving us the plus probabilities.
So after creating the structure of your neural network, you can also visualize this, a structure using
this.
Come on.
As I said earlier, our model is trying to optimize waits and biases that are represented by this number
to get down.
And if you remember interior lecture, we have discussed, death rates are assigned randomly for initialization
to get the information of those rates and biases.
There is a get underscored wait method that you can use to get information of those words and biases.
So I can write my object name.
That is mortal and then the layer number for the second layer.
I can write layers.
And then one since the location of object two is one.
And then I can use get three.
It's my turn.
I'm sorting this information into two new variables, weights and biases.
So if I just output the weights, you can see this are the randomly generated weights.
Are 784 and do 300 such weights in this layer.
So if you just view the shape, you can see that.
There are 784 rows and 300 columns, and there were weeks these all weights are randomly assigned for
an installation.
Similarly, we can also look at the bias as Bias's values biases are initialized as zero.
And if you just check the shape of biases, this should be 300.
You can see that there are 300 Bias's in the next video.
We will combine and train our model.
Thank you.