1
00:00:00,120 --> 00:00:04,760
So congratulations, you've just trained your first CNN network and by thoughts.

2
00:00:05,250 --> 00:00:06,960
And you can see the accuracy is quite good.

3
00:00:07,050 --> 00:00:08,520
Ninety seven point eighty eight percent.

4
00:00:09,180 --> 00:00:12,810
However, after seeing that score, what what can we do now?

5
00:00:13,260 --> 00:00:17,700
It feels a bit underwhelming in a way that we've created a school network that does this.

6
00:00:18,120 --> 00:00:20,040
But can we actually see it work?

7
00:00:20,400 --> 00:00:25,560
How do we input data into it and how do we re-use this model in future?

8
00:00:26,160 --> 00:00:29,490
So that's what we talk about this function called torture.

9
00:00:29,490 --> 00:00:30,090
Don't save.

10
00:00:30,760 --> 00:00:31,770
Now what we do.

11
00:00:31,800 --> 00:00:37,320
This allows us to save the model wins because remember the way sort of gradients of the model that we

12
00:00:37,320 --> 00:00:39,930
trained, that's essentially the model itself.

13
00:00:40,260 --> 00:00:41,400
It is, actually.

14
00:00:41,820 --> 00:00:48,620
So once we have the model structure, we can load those weights back into another set of good or in

15
00:00:48,620 --> 00:00:50,220
a different computer anywhere you want.

16
00:00:50,610 --> 00:00:56,610
So you just need a weights file and a model structure, and you can basically recreate your network

17
00:00:56,610 --> 00:00:57,900
and use it in any way you want.

18
00:00:58,410 --> 00:00:59,190
Make it portable.

19
00:00:59,700 --> 00:01:02,130
So to use torture to save all we do.

20
00:01:02,290 --> 00:01:03,690
Just specify a part here.

21
00:01:04,050 --> 00:01:06,630
This part can be directly pasted into here if you wanted.

22
00:01:07,860 --> 00:01:09,450
This is what I'm calling this model name.

23
00:01:09,810 --> 00:01:14,330
I'm calling it Amnesty, underscore CNN on the score net dot edge.

24
00:01:14,490 --> 00:01:17,390
That's the Python Watch model with its file.

25
00:01:17,820 --> 00:01:20,610
Usually the file or file, but can work.

26
00:01:21,150 --> 00:01:25,320
So to see if we used to watch Dot ceive open brackets.

27
00:01:25,320 --> 00:01:27,420
Net Dot Stick.

28
00:01:27,840 --> 00:01:35,550
That's basically gives the dictionary format of the width so close by to which are constructed in what

29
00:01:35,620 --> 00:01:38,970
weights in the relevant places and specified the part.

30
00:01:39,480 --> 00:01:40,260
And that's it.

31
00:01:40,410 --> 00:01:45,690
So if we run this, which I'll run for you guys here, you'll see this is a file here.

32
00:01:46,050 --> 00:01:52,050
If you wanted to download it for sentimental value, if you want to use it on your own PC, just download

33
00:01:52,050 --> 00:01:52,710
this network.

34
00:01:53,450 --> 00:01:54,120
It's pretty quick.

35
00:01:54,660 --> 00:01:55,360
And there we go.

36
00:01:55,450 --> 00:02:01,710
So we do have downloaded your first model that you trimmed, so we'll take a look at how we can use

37
00:02:01,710 --> 00:02:02,400
that afterward.

38
00:02:02,940 --> 00:02:05,270
But for now, let's take a look at something even cooler.

39
00:02:05,880 --> 00:02:10,920
Let's let's take a look at basically running some tests, getting some.

40
00:02:10,920 --> 00:02:12,840
First of all, let's get some test images out.

41
00:02:13,140 --> 00:02:15,960
What I'm going to do for you is I'm sorry for confusing in this lesson.

42
00:02:15,960 --> 00:02:17,160
I thought this was something else.

43
00:02:17,670 --> 00:02:22,320
What we're going to do now, we're going to take a look at some of the test data and then run that test

44
00:02:22,320 --> 00:02:25,970
data to our model and see what what the model outputs.

45
00:02:25,980 --> 00:02:28,530
Because remember, we were getting ninety seven point.

46
00:02:29,430 --> 00:02:29,910
What was it?

47
00:02:30,420 --> 00:02:34,770
Point eighty eight percent accuracy, which means it should pretty much get everything right.

48
00:02:35,040 --> 00:02:35,820
Most things right.

49
00:02:36,420 --> 00:02:37,860
So let's take a look at this.

50
00:02:37,860 --> 00:02:39,940
So let's display isn't the torch vision?

51
00:02:39,960 --> 00:02:42,130
Utilize some of our test data here.

52
00:02:42,150 --> 00:02:43,770
This is the ground truth labels for it.

53
00:02:44,160 --> 00:02:46,320
And this is our grid of images.

54
00:02:46,950 --> 00:02:48,150
This is zoom in for you guys.

55
00:02:49,020 --> 00:02:51,840
Now let's reload or reload the model.

56
00:02:51,840 --> 00:02:52,490
We just see it.

57
00:02:53,170 --> 00:02:59,430
So to do that, we have to create an instance of the model and move it to operations in memory and operations

58
00:02:59,760 --> 00:03:00,750
to the device.

59
00:03:00,930 --> 00:03:01,990
So we do that there.

60
00:03:02,490 --> 00:03:03,990
We just created the net.

61
00:03:04,080 --> 00:03:04,980
That's the class again.

62
00:03:05,190 --> 00:03:05,820
And that object.

63
00:03:06,270 --> 00:03:12,210
This time it's creating a new blank model doesn't have the weeds yet, sending the model to the GBU.

64
00:03:12,690 --> 00:03:16,410
Then we load using load undisclosed.

65
00:03:16,440 --> 00:03:22,230
It underscored that we lowered the PI torch model we just received, and that basically puts the weights

66
00:03:22,230 --> 00:03:22,980
onto the model.

67
00:03:23,250 --> 00:03:27,810
So we basically have the model that we just create by just running the simple line of code here.

68
00:03:29,280 --> 00:03:31,620
So now let's see how we can get some predictions out of it.

69
00:03:32,490 --> 00:03:35,490
So some of this quarter should look familiar to you.

70
00:03:36,150 --> 00:03:36,490
OK.

71
00:03:36,540 --> 00:03:42,240
Remember, we created to iterate, iterate over for a test later so we can get our test data here.

72
00:03:42,630 --> 00:03:48,410
We use test views, a dot next function in Python to get to labels and images out of it.

73
00:03:48,420 --> 00:03:49,410
That's the first batch.

74
00:03:49,920 --> 00:03:51,150
Then we move it to the CPU.

75
00:03:51,450 --> 00:03:53,100
Do you know why this should look familiar to you?

76
00:03:53,700 --> 00:03:57,890
This is what we've been doing in the training loop that scroll up to it over and over.

77
00:03:57,900 --> 00:04:04,620
We did it here to get the predictions of the test data, and we did it here during the training.

78
00:04:05,010 --> 00:04:06,510
So why are we doing that for?

79
00:04:07,020 --> 00:04:08,930
Well, let's go back to it.

80
00:04:10,620 --> 00:04:17,190
What we're doing here, we're basically taking some of the test data, feeding it to a model by just

81
00:04:17,190 --> 00:04:23,030
putting the images here, getting the outputs, getting the class probabilities biggest using torchlight

82
00:04:23,040 --> 00:04:23,520
max.

83
00:04:23,970 --> 00:04:28,170
The reason we use it to watch MAX function that gives us basically the class.

84
00:04:28,330 --> 00:04:31,110
I had the maximum probability score out of it.

85
00:04:31,680 --> 00:04:36,960
We use, we get it in the predicted variable here and then what we can do, we can just see the predictions

86
00:04:37,500 --> 00:04:41,190
displayed when using a list comprehension here to access it.

87
00:04:42,120 --> 00:04:47,580
Maybe I didn't mention this previously, but we will have to send it to the CPU and send it to number

88
00:04:47,910 --> 00:04:48,990
to printed out.

89
00:04:49,020 --> 00:04:51,790
It's just easier way to do it the other way.

90
00:04:51,790 --> 00:04:52,920
In the many ways you can do this.

91
00:04:53,370 --> 00:04:57,390
This is a way that I find it's quite quite simple and easy to access to values here.

92
00:04:57,750 --> 00:04:59,860
So 4G in this range here at.

93
00:04:59,940 --> 00:05:00,650
128.

94
00:05:01,020 --> 00:05:06,570
We get all of the values, predictive values from this predicted intensity here.

95
00:05:07,710 --> 00:05:12,000
So these are the values had predicted seven two one zero four one.

96
00:05:12,480 --> 00:05:13,770
Let's take a look at our image here.

97
00:05:14,280 --> 00:05:21,120
Seven to oh sorry, it's one zero one zero four one four nine.

98
00:05:21,870 --> 00:05:22,770
Yeah, it was.

99
00:05:23,460 --> 00:05:24,630
So this is pretty cool.

100
00:05:25,350 --> 00:05:28,950
There's another way I'll show you how to display these results in a much nicer format.

101
00:05:29,400 --> 00:05:31,380
But let's take a look at something else here.

102
00:05:32,440 --> 00:05:38,600
Remember, this was the part of the loop where we took home, where we display the accuracy.

103
00:05:38,610 --> 00:05:40,530
So if we just extracted, that could.

104
00:05:40,920 --> 00:05:45,840
From here, you can see what to watch Nevada, which is why we run inference in our model.

105
00:05:46,680 --> 00:05:48,110
We just take the little order here.

106
00:05:48,120 --> 00:05:54,600
We get the data out of it, move it to the GPU, passage in a network, get the predicted outputs,

107
00:05:55,170 --> 00:06:01,700
then get the accumulated total and correct how much is predicted correct here by using this function.

108
00:06:01,920 --> 00:06:06,420
This line here, and we just said these are basically the accumulators.

109
00:06:06,600 --> 00:06:08,040
That's why we set them to zero initially.

110
00:06:08,490 --> 00:06:13,800
So we can keep getting how much, how much it did, how much data, because this is going to be dollars

111
00:06:13,820 --> 00:06:14,310
in the end.

112
00:06:14,650 --> 00:06:17,520
And this is going to be some value nine, seven point eighty seven.

113
00:06:18,150 --> 00:06:18,930
So it's pretty cool.

114
00:06:19,140 --> 00:06:24,690
Then we just get the accuracy out of it so we can display as simply the accuracy out here as well,

115
00:06:25,140 --> 00:06:27,510
and we can set how much significant digits we wanted.

116
00:06:28,650 --> 00:06:30,870
So let's take a look at something else.

117
00:06:31,410 --> 00:06:33,480
Let's take a look at plotting what training looks.

118
00:06:33,810 --> 00:06:37,060
So I'll stop there and we'll go through this section afterwards.

119
00:06:37,290 --> 00:06:39,720
So thank you, and I'll stay tuned for the next section.
