1
00:00:11,060 --> 00:00:16,430
OK, so in this lecture, we are going to discuss how to make predictions with our trained and up neural

2
00:00:16,430 --> 00:00:17,070
network.

3
00:00:17,870 --> 00:00:23,000
Now, before we start this lecture, I want to mention that what we will do here is totally within your

4
00:00:23,000 --> 00:00:26,240
capabilities, using only what you've learned so far.

5
00:00:26,780 --> 00:00:31,520
So if you have not yet tried this yourself, please do so before watching this lecture.

6
00:00:32,150 --> 00:00:37,310
At this point, you should be able to take a raw string of text, convert it into the right format for

7
00:00:37,310 --> 00:00:41,360
a neural network, and then use a trained neural network to make a prediction.

8
00:00:41,900 --> 00:00:44,900
So please try that as an exercise before moving on.

9
00:00:46,700 --> 00:00:51,440
So one thing I have to mention is that these how to make prediction lectures are really made for the

10
00:00:51,440 --> 00:00:53,680
very, very beginner level students.

11
00:00:54,230 --> 00:00:59,900
That is, if you could not figure out how to do this by yourself, take this as a big danger sign.

12
00:01:00,740 --> 00:01:06,140
So my recommendation is that if you were waiting for this lecture or you believe that this lecture was

13
00:01:06,140 --> 00:01:12,320
necessary in order to teach you how to make predictions, then please take a moment to think about how

14
00:01:12,320 --> 00:01:13,610
much you have really learned.

15
00:01:14,210 --> 00:01:18,110
Consider whether you are actually learning or if you are just copying me.

16
00:01:18,740 --> 00:01:24,170
And if you find that you are the latter student, please pause right now and really put in some more

17
00:01:24,170 --> 00:01:27,110
effort into trying this exercise on your own.

18
00:01:29,100 --> 00:01:34,220
Now, you'll also notice that I've actually left the legacy version of this lecture in the course,

19
00:01:34,620 --> 00:01:36,840
I think this is useful for two reasons.

20
00:01:37,650 --> 00:01:43,290
Firstly, it covers topics like imbalance classes and the confusion matrix, which is unnecessary to

21
00:01:43,290 --> 00:01:44,270
repeat again.

22
00:01:45,180 --> 00:01:50,790
But secondly, and more importantly, I want you to notice how complex it is to use the torture text

23
00:01:50,790 --> 00:01:52,940
API for a simple prediction.

24
00:01:53,670 --> 00:01:55,490
It's actually surprisingly ugly.

25
00:01:56,190 --> 00:02:01,710
So I want you to watch that and compare it to this one to get a real understanding for why doing things

26
00:02:01,710 --> 00:02:05,020
yourself cannot only be useful, but preferable.

27
00:02:05,820 --> 00:02:11,490
Keep in mind that the torture text library is not even at version one, which means it is likely to

28
00:02:11,490 --> 00:02:13,190
change again in the near future.

29
00:02:13,770 --> 00:02:17,640
So there are many reasons why it's simply better to avoid using it.

30
00:02:18,150 --> 00:02:20,680
Learning it now is just not a good investment.

31
00:02:21,630 --> 00:02:27,570
As mentioned, I've seen multiple instances where courses simply use the CARUS text module instead,

32
00:02:28,200 --> 00:02:33,540
and with all that complexity you'll see that we can do the same thing here with just five very short

33
00:02:33,540 --> 00:02:34,540
lines of code.

34
00:02:35,520 --> 00:02:38,870
OK, so the first part of this notebook is all the same as before.

35
00:02:39,210 --> 00:02:41,100
So let's assume that the code has been run.

36
00:02:44,890 --> 00:02:49,000
The next step is to simply pick a random text that we want to classify.

37
00:02:49,870 --> 00:02:53,770
Alternatively, you can make up your own or draw a sample from the data set.

38
00:03:00,100 --> 00:03:05,650
The next step is to perform the usual preprocessing steps where we tokenized the text and then convert

39
00:03:05,650 --> 00:03:07,270
it into a list of integers.

40
00:03:12,120 --> 00:03:17,970
The next step is to convert our list of integers into a torch tensor, as you recall, this needs to

41
00:03:17,970 --> 00:03:24,690
be NBT, where end is the number of samples and to use the sequence length since we only have one sample.

42
00:03:24,720 --> 00:03:26,570
This is a one byte array.

43
00:03:30,980 --> 00:03:35,280
Now that our text is in the format we need for passing it into a neural network.

44
00:03:35,600 --> 00:03:39,260
The next step is to simply make the prediction using our trained model.

45
00:03:40,220 --> 00:03:45,200
Note that I've also move the tensor to the GPU since our model is also on the GPU.

46
00:03:49,520 --> 00:03:54,860
OK, so the final step, which doesn't really count, is a line of code, is to just print out the output.

47
00:03:57,790 --> 00:04:02,750
So as you can see, we get a very large number, which means that this would be a sign to spam.

48
00:04:03,400 --> 00:04:08,560
This makes sense, since if you read the above text, you can confirm that it is, in fact, a spam

49
00:04:08,560 --> 00:04:11,140
message as an exercise.

50
00:04:11,170 --> 00:04:16,330
Think about why this output value is not between zero and one, as you may have expected.
