Planning is one of the machine learning algorithms that is uses a neuron, an artificial neuron, neurons
that that is connected between each other to recognize or to extract some patterns and make decisions.
Of course, these neurons, we have to construct them.
However, we don't have to explicitly program every one of them.
The the tuning this neural network is a process in which we call training.
So.
So how do we tune these neural network?
Well, every neural network is simply a value holder.
Every neural will have a simple value, only a value.
And these values will be will, will, will pass on the the value its value to the next neural network
or the connected neural network.
As it passes through this neural network, it will be multiplied by weight and will be summed by a value
called bias.
We don't control directly the value of the neural network or the actual neuron.
However, we directly control the weight of this A that is going to be multiplied in order to pass on
to the other neuron.
And we we we actually control the bias in which simply the summation added to the weight multiplied
the value of this neuron.
So how it looks like.
Well, if we have a data with an input value, for example, X1X2X3X4 and a target value of let's say
we try to classify something.
So it's it's 0 or 1.
We simply add these ones to be every value will be x1, x2, x3 and x4 as a as an input layer of specific
values.
And these values will be passed on to some layers.
Here we call it hidden layers.
And after that, of course, depending on the architecture will be passed on to the resulting layers,
which is in this case the output layers of zero and one.
The.
The hidden layers will get its value from the input layer.
And after we start initializing these weights and biases after.
After we initialize it, we will have it checked.
If it's going to provide us the zero and one we want, or there will be some error.
The error we call it in this or this analogy is we call it loss.
And based on this loss, we will update our weights and biases until we get as as good as possible or
as as near as possible value for zero and one for the data we have.
Now, as we said, we will multiply every a neural network value with the weight and we sum it with
the bias and we will pass it into a function.
This functions, we call it activation functions.
And in our neural networks, we simply we can we can choose any function we want.
However, we need to test some functions in order to get a good answer.
One of the most popular functions are activation functions is Relu function in which if the value is
is minus of that neural network, it will just return zero.
And if the value is positive, it will return that value.
Now another popular function is sigmoid function, which is it has this graph that at the end it will
provide the output of every neuron is between 0 and 1.
As you can see, it is bounded by zero.
And here is one and another one is leaky Relu, which is if we have a minus value, it will provide
a very small, leaky value.
A very small value.
This is why we call it Relu.
And if it's positive, it will give.
It will provide the same value.
So these functions, however, would say the most now commonly used is the Relu.
However, you can see different architectures of neural networks that they use, different activation
functions.
Now cost functions.
Again, as we said, we will have input layer and then output layer and the output layer is is made
of values.
We predicted it, which is based on our weights and biases of the whole network and we need to compare
it with the values That is real values.
This is in our training data.
We we always have cases.
We try the input with our already made weights and biases, and then we will compare it with the actual
output that we have.
And based on that, we will calculate the loss.
And the loss in, in the simplest way is we can use, for example, mean square cost function, which
is the same mean mean squared error.
We already know from previous lectures is a simple as we minus the value we predicted minus our real
value.
And it's going to be squared.
In.
In the in the another value is we call cross entropy cost function.
And it has a different formula that is or was based on the idea of a comparing the actual value or the
expected value with the sorry, with the expected value from our network.
That is, we predicted it based on our or our input and our current weights and biases of the network
with the actual value of that training data.
For example, if we're comparing if we have an input layer of an image of a dog and the result was a
we should be a dog should be one and a cat should be zero, if we have not, if we have the opposite,
that means the weight has to be updated in order to match this this output, which should give us a
dog because the image is a dog.
Now, how do we do that?
Like we we can understand that in a big network there is a huge amount of weights and biases and well,
we need to tune it.
And the problem with tuning, we need a optimizer because of course we can tune it by ourselves, by
our hands.
But it's not very practical and it's I'm not sure if it's even possible.
So to to to do that, we need Optimizer in which we will take these parameters and we try to try to
reduce the loss as much as possible.
One of the early and also used optimizers is the gradient descent.
And the gradient descent is is about simple idea.
That is, we have a function or we have these all these parameters and we need to check these parameters
how we can always reduce the loss.
And as we reduce the loss, we, we, we change our step size.
For example, we can start at the beginning a little bit, big step sizes, and then we start going
smaller as we go.
Of course, it's, it's, it's always if we have a bigger step size, we will, we will get to the optimization
value quicker.
However, if we have too small, but however if we have too big that we might never get to the actual
value because we can go from here to here and we will.
We will just miss the minima that we are looking for to reduce the loss.
And we cannot also go very small because simply it will take too much time.
So we need to always kind of balance these two things, like the step size and another maybe more used
method is the back propagation and back propagation is, is is based on the idea of we start with with
of course we will have the, the network with our initial weights and biases and we start from the output
of this network and we go in the opposite direction.
For that is this is what we call back propagation.
We start from the back of the network and we can see the expected value we have.
And what is the effect of changing these weights on the expected value we have, depending on the difference
that between what we can change?
And how we can get closer to these a the output value.
We will change the weights and biases of the of this network.
And after that we will predict the values of the the the layer just behind the the output layer.
And we keep doing the same to the layer behind it and the layer behind it and so on until we get to
the to the first layer.
So this is basically the idea of back propagation.
Of course we have to do it for a lot of data and or patches of data.
And with these patches of data, every data depend on the, the, the, the loss value.
We will update the weights a little bit more, a little bit smaller and and so on.
The overall, we should have a model that will work well for that batch and then we will get another
patch that we tested and then we update the weights and biases and so on and so on.
So we will of course not going to train the data in like as a whole, we will split the data into patches
and this patches will go into the network and we get trained and with time we will keep getting closer
and closer to a at the lowest possible loss.