1
00:00:00,120 --> 00:00:01,170
Hi and welcome back.

2
00:00:01,530 --> 00:00:07,740
In this section, we'll take a look at using PyTorch to build a very simple Ottoman quarter on the fashion

3
00:00:07,740 --> 00:00:08,610
amnesty to set.

4
00:00:08,730 --> 00:00:09,810
So let's get started.

5
00:00:09,840 --> 00:00:13,870
So open notebook though here and let's begin to listen.

6
00:00:13,890 --> 00:00:20,820
So this is just a recap on the auto encoder architecture and some notes on it, as well as the tutorial

7
00:00:20,820 --> 00:00:24,780
credits here so you can visit this website gives this guy some kudos.

8
00:00:25,470 --> 00:00:28,650
So firstly, let's load and pre process.

9
00:00:28,860 --> 00:00:35,040
This should be six French would pre process our f f a. EFT amnesty to set?

10
00:00:35,040 --> 00:00:36,390
That's a fashion in this data set.

11
00:00:36,990 --> 00:00:43,980
So let's little libraries here, and I have too many sessions open, so we're going to close the use.

12
00:00:43,980 --> 00:00:47,310
This is a very cool project you'll be doing later on in this course.

13
00:00:48,780 --> 00:00:56,570
So, OK, so let's run this again and it'll connect to virtual machine cloud instance.

14
00:00:56,580 --> 00:00:59,070
And then we go, Where did you?

15
00:00:59,430 --> 00:01:00,390
Great to know.

16
00:01:01,230 --> 00:01:10,200
Always check your GPU for these lessons to CNN, these neural net lessons and know that just to find

17
00:01:10,200 --> 00:01:12,090
some of the variables here.

18
00:01:12,570 --> 00:01:18,420
So we're going to be training at 50 epochs with a leading rate of zero point zero zero one and about

19
00:01:18,420 --> 00:01:23,520
sides is going to be 128 and image transforms are just simply converting them to a tensor.

20
00:01:23,520 --> 00:01:28,290
There's no normalization or any fancy fancy transformations being done in there.

21
00:01:29,040 --> 00:01:31,460
And then we just create our data loaders here.

22
00:01:31,470 --> 00:01:34,480
So we're learning from the fashion and this dataset here.

23
00:01:35,050 --> 00:01:41,670
I was downloading the training dataset here, as well as for the test dataset.

24
00:01:41,670 --> 00:01:43,300
We just set the training all false.

25
00:01:43,320 --> 00:01:48,450
You've done this before, but it's a good recap and let's load that data.

26
00:01:49,530 --> 00:01:54,570
Specify what transforms have been deprived above, and we're good to go.

27
00:01:55,050 --> 00:02:01,440
Now we can create what data loaders and we just simply specify if we want it.

28
00:02:01,440 --> 00:02:07,590
From this know about size, we defined this 128 before we'll be shuffling both of them in this case.

29
00:02:08,370 --> 00:02:13,650
And now let's create some utility functions before we actually create or to include a model.

30
00:02:14,100 --> 00:02:18,810
So this is a very simple one to get device to to tell us what device we're using.

31
00:02:19,380 --> 00:02:25,350
Then we also have a make directory so we can install the directory images here, as well as saving this,

32
00:02:25,470 --> 00:02:26,610
this output images.

33
00:02:27,060 --> 00:02:31,890
So let's just create those functions and now we can create or to encode a model.

34
00:02:32,460 --> 00:02:39,510
So notice one thing here in this lesson we aren't using convolutional layers to to do on coding and

35
00:02:39,510 --> 00:02:40,020
decoding.

36
00:02:40,500 --> 00:02:44,300
We're using regular, fully connected, linearly layers.

37
00:02:44,790 --> 00:02:50,550
We know this is a good idea for when the image size is small, like in fashion, amnesty and amnesty,

38
00:02:50,550 --> 00:02:50,910
the said.

39
00:02:51,800 --> 00:02:58,080
It doesn't because it doesn't become unfathomably big when we have images of that size, and they're

40
00:02:58,080 --> 00:03:01,290
also just one dimensional images, meaning that grayscale.

41
00:03:01,710 --> 00:03:02,560
So it's not too bad.

42
00:03:02,580 --> 00:03:06,680
However, I would not recommend this method for larger color images.

43
00:03:06,690 --> 00:03:12,000
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

44
00:03:12,300 --> 00:03:13,590
CNN layers here.

45
00:03:13,740 --> 00:03:17,850
But for now, we'll use this to illustrate the purpose of what the input is.

46
00:03:18,270 --> 00:03:21,900
So you can see our input features a 728 734.

47
00:03:21,900 --> 00:03:26,550
Sorry, that's 28 by 28, and output size is going to be 256.

48
00:03:26,550 --> 00:03:33,330
And you can see that's that leads to this layer and it goes on all the way to 16, just 16 bits.

49
00:03:33,900 --> 00:03:38,800
And then we go up here, we just go back all the way up from 16 to 784.

50
00:03:39,270 --> 00:03:40,850
That's in the dual phase.

51
00:03:41,330 --> 00:03:46,320
This is the encode phase, and the forward loop is basically we just run these things together.

52
00:03:46,320 --> 00:03:51,120
So it's in a sequential order so you can see where you play really is activation function.

53
00:03:51,630 --> 00:03:54,330
And we just have a encoder here and kiss and redo.

54
00:03:54,690 --> 00:04:00,120
But X gives us the algorithm access to X back again and so on, and then returned to file output.

55
00:04:00,120 --> 00:04:01,170
Do so.

56
00:04:01,170 --> 00:04:03,630
Let's create or to encode a model.

57
00:04:04,680 --> 00:04:05,280
And then we go.

58
00:04:05,730 --> 00:04:11,940
So we have a model with our coming down here to a bottleneck layers and then coming back up to upwardly

59
00:04:11,940 --> 00:04:12,300
is here.

60
00:04:12,840 --> 00:04:15,120
So now let's define for lost function.

61
00:04:15,130 --> 00:04:22,530
So we're using the MSI loss this time and we're using Adam Optimizer and now we can train our model.

62
00:04:23,010 --> 00:04:27,210
So I'm not going to go into too much detail with a training loop here because you've seen this before.

63
00:04:27,720 --> 00:04:32,820
But there's nothing really different with the auto encoder training, except that where the training

64
00:04:32,820 --> 00:04:38,910
data itself is and the test data entering data, all the same things I remember from all lesson.

65
00:04:39,390 --> 00:04:43,650
So this is a training function here, and this is our test image reconstruction.

66
00:04:44,070 --> 00:04:50,190
What this does is takes the network equivalent and takes a test tester to loader and then passes, gets

67
00:04:50,190 --> 00:04:54,400
a match day and runs a truly network that we've trained and saves images back.

68
00:04:54,410 --> 00:04:56,910
And the output does this for one batch of images here.

69
00:04:57,660 --> 00:04:59,940
So it's a way we can run inference and get the output.

70
00:05:00,440 --> 00:05:01,540
A photo encoder.

71
00:05:01,760 --> 00:05:04,730
So now we're ready to train our network.

72
00:05:05,360 --> 00:05:08,390
So let's go ahead and train this network.

73
00:05:08,810 --> 00:05:14,140
You can see we just get the device from the device, make the directory at restoring images and then

74
00:05:14,150 --> 00:05:16,240
this is this is where we trained the network.

75
00:05:16,250 --> 00:05:21,800
So we're passing them at the network, fastening the training data that we're looking at, as well as

76
00:05:21,800 --> 00:05:22,700
a number of ebooks.

77
00:05:22,700 --> 00:05:30,170
And then at the end, we just plot just put some lofty training results after.

78
00:05:32,430 --> 00:05:39,630
So let's run, this may take a little while to train, so just be patient and we'll wait for it.

79
00:05:48,200 --> 00:05:53,360
OK, and we're done training, and you can see we have very little loss here, and actually, in fact,

80
00:05:53,930 --> 00:05:57,520
it stopped decreasing at roughly 25 e-books, but we didn't know that.

81
00:05:57,530 --> 00:06:02,390
So 50 was a safe number to go into could have reduced even further if we left it for longer.

82
00:06:02,810 --> 00:06:05,840
But that might be diminishing with hints at that point.

83
00:06:06,350 --> 00:06:07,930
So this is quite good results.

84
00:06:07,940 --> 00:06:11,930
So now let's take a look at displaying our image reconstruction.

85
00:06:11,940 --> 00:06:13,430
So what are we looking at here?

86
00:06:13,910 --> 00:06:19,020
Well, this is actually the reconstructed images from that auto included.

87
00:06:19,040 --> 00:06:20,860
Remember it don't scale to the image.

88
00:06:20,870 --> 00:06:26,570
Well, not downscaled, but don't sample the image tremendously so that we reduced the size, said the

89
00:06:26,570 --> 00:06:28,820
bits that stored the image information.

90
00:06:29,300 --> 00:06:33,860
And then we upscale it again with the Decoy Italia and we get this snow.

91
00:06:34,070 --> 00:06:35,330
Well, it looks quite good.

92
00:06:35,390 --> 00:06:41,880
You can see this some sporadic missing dots or pixels of data, which means the autumn.

93
00:06:41,900 --> 00:06:47,390
In quite a while, it learned that the representation quite well wasn't able to completely learn everything.

94
00:06:47,390 --> 00:06:50,930
I don't know why that's happening, but it's interesting.

95
00:06:51,020 --> 00:06:52,670
It's it's an interesting result.

96
00:06:53,300 --> 00:06:58,730
Now you can take a look at the original image here, and you can see the original images are a lot cleaner

97
00:06:58,730 --> 00:07:01,670
looking and they don't have those dots in them.

98
00:07:02,090 --> 00:07:04,190
Go back to our decoders.

99
00:07:04,610 --> 00:07:06,980
You can see things are slightly less detailed.

100
00:07:06,980 --> 00:07:09,650
Things like shoes, especially a bit more blurry.

101
00:07:10,520 --> 00:07:16,430
But generally the auto could lived quite a bit and is able to reconstruct some images quite nicely.

102
00:07:16,820 --> 00:07:22,280
I think we'd maybe need a little bit more bits to store these types of images because this is a lot

103
00:07:22,280 --> 00:07:24,470
more complex than the amnesty.

104
00:07:24,470 --> 00:07:29,630
To said, it's a lot more information still like a lot more details in the fashion than this, as opposed

105
00:07:29,630 --> 00:07:33,390
to digits policy, a lot more variation in this dataset.

106
00:07:33,890 --> 00:07:39,110
So you can see the results are not quite as good as some, not as good ones we got with the embassy

107
00:07:39,110 --> 00:07:39,470
to set.

108
00:07:39,950 --> 00:07:43,400
However, I'm quite happy with this and I hope you are too.

109
00:07:43,550 --> 00:07:51,470
So that concludes this lesson here on using the auto incluidas in PyTorch with the fashion in this dataset.

110
00:07:51,980 --> 00:07:59,030
Now we'll move on to something even cooler, which is guns, which are generative, adversarial neural

111
00:07:59,030 --> 00:07:59,570
networks.

112
00:07:59,960 --> 00:08:01,110
So stay tuned for that.

113
00:08:01,190 --> 00:08:01,640
Thank you.
