So welcome back to the lesson.
So now we're going to talk about Transformers.
So what a transformers and why they used.
Well, let's take a look at something here.
Let's look at a code before we go over the explanation of all of this.
Now, when we load data into our deep learning libraries, we want to normalize and standardized that
data for several reasons.
Having data that's not normalized can cause a lot of issues in training and place a lot more importance
on other variables or the pixels in our case when it shouldn't.
So if you want to normalize a values, a good way to do it is just scale the values because initially
the Candice line here or a raw pixel values in the amnesty to set range from zero to 255, which you
would have seen an expensive innocence that that's basically the default.
We would scale of unrepresented densities of colors and intensity of greens as a grayscale image.
So this range of zero to 255.
And when we have to normalize it, a good normalization of practice is to set to range from one to minus
one.
That way, we have that negative positive balance and then not knowing none of the pixel values can
have like super high weighting compared to the others.
It's just something that the bleeding practitioners have observed that normalization improve things
drastically, so it's always a good practice to normalize.
No, you don't have to, but it's a very good practice.
So what transforms do?
Basically, this is a towards functional towards vision function that allows us to create a pipeline.
And this pipeline basically is an operation that performs a series of events, a series of operations
on the image before sending it into the neural net, the tree.
So the first function that we have to do is use watch transforms to Tensor.
This converts the image from the so that we loaded into a PyTorch tensor, and our python tensor is
basically the same.
Remember your arrays and list and nampai representations of images.
A PyTorch tensor is basically the Dutch version of that.
It's just a matrix, but it's an intensive form which allows us to use to be to use these these sensors
on GPUs.
So that's a first normalization type of operation that we use.
The second one is the normalization, one which we just spoke, spoke about.
Now these parameters could look confusing.
Why 0.5 by 0.5?
Well, there's a reason for that, and that's because we want to normalize between one and minus one.
So how does setting this point five, ten point five do that?
Well, this normalization function takes into consideration in tuples as the input Typekit.
This one is four min, one is four standard deviation.
So because we're using for a grayscale image we took, we just put a comma here to see that to balance
the tuple data type standard.
And we don't put in the other two point five because if you look at this line here, four color images
or even this line here for RGV color images, we will use point five point five point five and point
five point five point five, meaning that resetting the mean for all the RGV titles two point five and
the standard deviation destiny two point five point five point five on dudded.
That's why we have these values.
And no, this is how the normalization is done.
Why?
Point five.
Well, image output imaging ActionScript is equal to the image input image minus two mean divided by
the deviation.
This is how we scale the values between the one and minus one.
So the minimum value would be zero minus point five divided, but four point five is equal to one,
and a max value takes this formula as well.
And that's how we end up.
We use this formula to scale the image data between one and minus one.
It's quite simple.
So that takes care of our normalization or transformation that does normalization here.
You can do a lot more different transformations here, but we'll talk about that at least lessons.
But for now, this is what we're going to need to go to use.
So let's stop there, and in the next section, we'll take a look and inspect our dataset.
We'll visualize it and understand the dimensions of it.
So I'll see you in the next section.