Hi and welcome back.
In this section, we'll take a look at using PyTorch to build a very simple Ottoman quarter on the fashion
amnesty to set.
So let's get started.
So open notebook though here and let's begin to listen.
So this is just a recap on the auto encoder architecture and some notes on it, as well as the tutorial
credits here so you can visit this website gives this guy some kudos.
So firstly, let's load and pre process.
This should be six French would pre process our f f a. EFT amnesty to set?
That's a fashion in this data set.
So let's little libraries here, and I have too many sessions open, so we're going to close the use.
This is a very cool project you'll be doing later on in this course.
So, OK, so let's run this again and it'll connect to virtual machine cloud instance.
And then we go, Where did you?
Great to know.
Always check your GPU for these lessons to CNN, these neural net lessons and know that just to find
some of the variables here.
So we're going to be training at 50 epochs with a leading rate of zero point zero zero one and about
sides is going to be 128 and image transforms are just simply converting them to a tensor.
There's no normalization or any fancy fancy transformations being done in there.
And then we just create our data loaders here.
So we're learning from the fashion and this dataset here.
I was downloading the training dataset here, as well as for the test dataset.
We just set the training all false.
You've done this before, but it's a good recap and let's load that data.
Specify what transforms have been deprived above, and we're good to go.
Now we can create what data loaders and we just simply specify if we want it.
From this know about size, we defined this 128 before we'll be shuffling both of them in this case.
And now let's create some utility functions before we actually create or to include a model.
So this is a very simple one to get device to to tell us what device we're using.
Then we also have a make directory so we can install the directory images here, as well as saving this,
this output images.
So let's just create those functions and now we can create or to encode a model.
So notice one thing here in this lesson we aren't using convolutional layers to to do on coding and
decoding.
We're using regular, fully connected, linearly layers.
We know this is a good idea for when the image size is small, like in fashion, amnesty and amnesty,
the said.
It doesn't because it doesn't become unfathomably big when we have images of that size, and they're
also just one dimensional images, meaning that grayscale.
So it's not too bad.
However, I would not recommend this method for larger color images.
It's going to be way too slow to trim, and you're going to get a lot more bang for your buck by using
CNN layers here.
But for now, we'll use this to illustrate the purpose of what the input is.
So you can see our input features a 728 734.
Sorry, that's 28 by 28, and output size is going to be 256.
And you can see that's that leads to this layer and it goes on all the way to 16, just 16 bits.
And then we go up here, we just go back all the way up from 16 to 784.
That's in the dual phase.
This is the encode phase, and the forward loop is basically we just run these things together.
So it's in a sequential order so you can see where you play really is activation function.
And we just have a encoder here and kiss and redo.
But X gives us the algorithm access to X back again and so on, and then returned to file output.
Do so.
Let's create or to encode a model.
And then we go.
So we have a model with our coming down here to a bottleneck layers and then coming back up to upwardly
is here.
So now let's define for lost function.
So we're using the MSI loss this time and we're using Adam Optimizer and now we can train our model.
So I'm not going to go into too much detail with a training loop here because you've seen this before.
But there's nothing really different with the auto encoder training, except that where the training
data itself is and the test data entering data, all the same things I remember from all lesson.
So this is a training function here, and this is our test image reconstruction.
What this does is takes the network equivalent and takes a test tester to loader and then passes, gets
a match day and runs a truly network that we've trained and saves images back.
And the output does this for one batch of images here.
So it's a way we can run inference and get the output.
A photo encoder.
So now we're ready to train our network.
So let's go ahead and train this network.
You can see we just get the device from the device, make the directory at restoring images and then
this is this is where we trained the network.
So we're passing them at the network, fastening the training data that we're looking at, as well as
a number of ebooks.
And then at the end, we just plot just put some lofty training results after.
So let's run, this may take a little while to train, so just be patient and we'll wait for it.
OK, and we're done training, and you can see we have very little loss here, and actually, in fact,
it stopped decreasing at roughly 25 e-books, but we didn't know that.
So 50 was a safe number to go into could have reduced even further if we left it for longer.
But that might be diminishing with hints at that point.
So this is quite good results.
So now let's take a look at displaying our image reconstruction.
So what are we looking at here?
Well, this is actually the reconstructed images from that auto included.
Remember it don't scale to the image.
Well, not downscaled, but don't sample the image tremendously so that we reduced the size, said the
bits that stored the image information.
And then we upscale it again with the Decoy Italia and we get this snow.
Well, it looks quite good.
You can see this some sporadic missing dots or pixels of data, which means the autumn.
In quite a while, it learned that the representation quite well wasn't able to completely learn everything.
I don't know why that's happening, but it's interesting.
It's it's an interesting result.
Now you can take a look at the original image here, and you can see the original images are a lot cleaner
looking and they don't have those dots in them.
Go back to our decoders.
You can see things are slightly less detailed.
Things like shoes, especially a bit more blurry.
But generally the auto could lived quite a bit and is able to reconstruct some images quite nicely.
I think we'd maybe need a little bit more bits to store these types of images because this is a lot
more complex than the amnesty.
To said, it's a lot more information still like a lot more details in the fashion than this, as opposed
to digits policy, a lot more variation in this dataset.
So you can see the results are not quite as good as some, not as good ones we got with the embassy
to set.
However, I'm quite happy with this and I hope you are too.
So that concludes this lesson here on using the auto incluidas in PyTorch with the fashion in this dataset.
Now we'll move on to something even cooler, which is guns, which are generative, adversarial neural
networks.
So stay tuned for that.
Thank you.