1
00:00:00,330 --> 00:00:05,730
And welcome to the lesson where we basically do the same thing that we just did in Kansas, but no in

2
00:00:05,730 --> 00:00:11,520
pie too much, and that same thing refers to identifying the mis classifications of the model that we

3
00:00:11,520 --> 00:00:18,060
previously trained on the M.A. handwritten digit dataset, as well as generate the confusion matrix

4
00:00:18,060 --> 00:00:20,310
and the classification report.

5
00:00:20,460 --> 00:00:25,800
So open notebook for that's this one right here, which I really have done already.

6
00:00:25,800 --> 00:00:27,300
And let's take a look at the lesson.

7
00:00:27,870 --> 00:00:35,670
So before it, before we load on model learning models isn't as simple as as it is in Keros when in

8
00:00:35,670 --> 00:00:36,270
pie too much.

9
00:00:36,810 --> 00:00:41,730
And that's because we have to define the model architecture prior, so we have to set up the middle

10
00:00:41,730 --> 00:00:45,600
class and define everything before we actually load the model in this case.

11
00:00:46,170 --> 00:00:48,120
So let's let's end to do that.

12
00:00:48,120 --> 00:00:50,610
We actually have to import all of these pie touch functions again.

13
00:00:50,730 --> 00:00:52,020
So let's do that here.

14
00:00:53,730 --> 00:00:54,170
There we go.

15
00:00:54,210 --> 00:00:57,090
So it's loaded and we are using the GPU, which is good.

16
00:00:57,540 --> 00:00:59,910
Let's look at the image plotting function.

17
00:01:00,210 --> 00:01:02,550
And no, that's LoDo minus test data.

18
00:01:02,970 --> 00:01:04,770
What are you going to look at to test data here?

19
00:01:04,860 --> 00:01:10,650
So to do this, like previously, what we've seen before is that you define the transforms here.

20
00:01:10,650 --> 00:01:16,590
We converting it to tensor or normalizing between minus one and one by setting the mean and standard

21
00:01:16,590 --> 00:01:22,650
deviation two point five we are using towards efficient data sets amnesty to load the testator.

22
00:01:22,650 --> 00:01:24,150
That's why trade is false.

23
00:01:24,540 --> 00:01:26,700
We have to transform that we defined here.

24
00:01:27,210 --> 00:01:31,920
And then we're creating a digital order out of test sets here where we specified a batch size.

25
00:01:32,070 --> 00:01:35,940
We won't be shuffling no work as a zero, so let's run.

26
00:01:35,940 --> 00:01:38,130
All of this now should run quickly.

27
00:01:38,880 --> 00:01:39,330
There we go.

28
00:01:39,540 --> 00:01:43,650
So now we have to define or create or model that definition class.

29
00:01:44,100 --> 00:01:46,860
This is a model that we trained previously in the previous lesson.

30
00:01:47,490 --> 00:01:53,250
So you can see it as a standard PyTorch model structure that we were using here and then.

31
00:01:53,250 --> 00:01:57,240
Now we've done a little model that was saved to make a good Google drive previously.

32
00:01:58,170 --> 00:02:04,080
And only now we can actually create the instance of the model and then load the state dictionary of

33
00:02:04,080 --> 00:02:09,300
the model by using Torture Lord, and we pointed the file right here that we've downloaded.

34
00:02:10,050 --> 00:02:12,180
So let's do that now.

35
00:02:12,840 --> 00:02:15,030
And our model is now loaded.

36
00:02:17,620 --> 00:02:18,160
There we go.

37
00:02:18,190 --> 00:02:19,630
So it's a concern.

38
00:02:20,320 --> 00:02:23,200
So, no, you would have seen this in the previous lesson here.

39
00:02:23,740 --> 00:02:29,650
So we just use with torture no grid, which is basically what we do when we're running inference on

40
00:02:29,650 --> 00:02:32,980
a model A deactivates the autocratic engine.

41
00:02:33,490 --> 00:02:38,740
This allows it to reduce memory usage and speed up computations, which is why we use it in inference.

42
00:02:39,220 --> 00:02:41,850
So we just want sitting ducks here.

43
00:02:41,860 --> 00:02:49,150
We just use automated loader, which is either irritable and for so for data inside of it, we just

44
00:02:49,150 --> 00:02:50,760
get the images and labels out of it.

45
00:02:50,770 --> 00:02:54,160
Move it to the GPU, which is done in these lines here.

46
00:02:54,640 --> 00:03:01,300
Then the default propagation with this batch of images here into the network get the outputs then used

47
00:03:01,300 --> 00:03:04,240
to watch that max to get the predictions out of it.

48
00:03:04,720 --> 00:03:09,130
And then we just do it to the accumulation for total number of levels, correct?

49
00:03:09,250 --> 00:03:14,380
So total number of labels being examined, then total number of labels that were correct in this line

50
00:03:14,380 --> 00:03:21,040
of code here and then just print the overall accuracy in the end of correct over total.

51
00:03:21,610 --> 00:03:28,150
So let's run this, which you have seen before in the previous lesson, and our model has ninety eight

52
00:03:28,150 --> 00:03:29,500
point seven percent accuracy.

53
00:03:29,500 --> 00:03:33,340
It's better, better than the model that we loaded for accuracy dataset.

54
00:03:34,210 --> 00:03:38,230
So, no, let's take a look at this polling on this classified images.

55
00:03:38,830 --> 00:03:44,680
So as I said here, out of 10000 images, we have predicted many 8.7 percent correct, which is pretty

56
00:03:44,680 --> 00:03:44,930
good.

57
00:03:44,950 --> 00:03:46,690
However, we can get a lot better.

58
00:03:47,290 --> 00:03:53,350
So a good practice, and it's a good habit when you're creating image classifiers to always examine

59
00:03:53,350 --> 00:03:54,640
the misclassified images.

60
00:03:55,090 --> 00:04:01,060
So that's what I mentioned in the Keras lesson, because you always want to see which what your model

61
00:04:01,060 --> 00:04:06,550
is struggling, that why and you can figure out why and then make adjustments to your model or to your

62
00:04:06,550 --> 00:04:10,600
data processing or image augmentation pipeline to understand.

63
00:04:10,900 --> 00:04:12,010
So let's keep going.

64
00:04:13,390 --> 00:04:14,950
And these are some reminder notes here.

65
00:04:15,370 --> 00:04:19,300
In case you're wondering why we use native and towards undergrad as well.

66
00:04:21,310 --> 00:04:24,640
So this sets the evaluation mode here for to inference again.

67
00:04:25,330 --> 00:04:27,970
And we just do the same thing here with torsional grad.

68
00:04:28,150 --> 00:04:30,250
So we just don't need a gradient validation.

69
00:04:30,250 --> 00:04:34,570
So we just wrap it in and we have no grad, which saves us memory.

70
00:04:35,890 --> 00:04:40,210
Take our data from a test data to go through the process again.

71
00:04:40,750 --> 00:04:41,660
So when you're ready?

72
00:04:41,680 --> 00:04:43,510
Just run this block of code here.

73
00:04:43,510 --> 00:04:48,770
And what's happening here is that we're inspecting each prediction here, so we're checking to see if

74
00:04:48,770 --> 00:04:51,870
the prediction is correct or not.

75
00:04:51,880 --> 00:04:57,220
By this, let this look in this paper, and if it's not correct, we're just printing the actual label,

76
00:04:57,220 --> 00:05:02,560
predicting the printed label, reshaping the image so that we can actually plot it here and then using

77
00:05:02,560 --> 00:05:06,190
the initial function we defined previously to display the image.

78
00:05:06,430 --> 00:05:10,600
So you can see we have no 128 samples of the batch.

79
00:05:11,590 --> 00:05:12,790
It's actually actually not all the batch.

80
00:05:12,790 --> 00:05:17,140
This is actually the full, all the misclassified images here.

81
00:05:17,650 --> 00:05:22,180
So it's quite large number, I would imagine, but not as large as 500 from the Keras ones, probably

82
00:05:22,180 --> 00:05:25,150
like about 200 and something, and you can see them here.

83
00:05:25,150 --> 00:05:28,410
So you can see the actual label was a tree predictive it.

84
00:05:28,500 --> 00:05:32,370
It's understandable, actually, there was a four, a nine.

85
00:05:32,440 --> 00:05:36,340
This one does look like a bit like like a nine, though, so it's understandable.

86
00:05:36,880 --> 00:05:40,780
So you can expect it to and you can see this one looks like a scorpion, actually.

87
00:05:41,260 --> 00:05:49,120
But it's it's actually it's probably the spin skipped here and in particular to inadvertently this one

88
00:05:49,120 --> 00:05:51,070
looks like one predicted of it.

89
00:05:51,130 --> 00:05:52,630
Maybe because it's a tick one.

90
00:05:53,290 --> 00:05:56,350
This one inflicted one, but it's actually a two.

91
00:05:56,740 --> 00:06:01,840
So you can see it's doing quite well and the classes, it's making mistakes actually, classes that

92
00:06:01,840 --> 00:06:06,520
some humans can make mistakes identifying too like this one is actually, I mean, it's a tree, but

93
00:06:06,520 --> 00:06:09,940
it's honestly, it's not that visible that it's a tree.

94
00:06:10,330 --> 00:06:11,260
It's not that appearance.

95
00:06:12,220 --> 00:06:15,310
So let's keep going and we can examine the all of the glasses here.

96
00:06:15,670 --> 00:06:18,310
But generally, you can see your model is doing quite well.

97
00:06:18,580 --> 00:06:20,110
Let's delete this block here.

98
00:06:21,250 --> 00:06:26,740
Now we'll stop there for now, and in the next section, we'll take a look at generating a confusion

99
00:06:26,740 --> 00:06:29,530
matrix as well as a classification report.

100
00:06:29,650 --> 00:06:31,300
So I'll see you in the next section.

101
00:06:31,480 --> 00:06:31,900
Thank you.
