OK, so in this lecture, we are going to discuss how to make predictions with our trained and up neural
network.
Now, before we start this lecture, I want to mention that what we will do here is totally within your
capabilities, using only what you've learned so far.
So if you have not yet tried this yourself, please do so before watching this lecture.
At this point, you should be able to take a raw string of text, convert it into the right format for
a neural network, and then use a trained neural network to make a prediction.
So please try that as an exercise before moving on.
So one thing I have to mention is that these how to make prediction lectures are really made for the
very, very beginner level students.
That is, if you could not figure out how to do this by yourself, take this as a big danger sign.
So my recommendation is that if you were waiting for this lecture or you believe that this lecture was
necessary in order to teach you how to make predictions, then please take a moment to think about how
much you have really learned.
Consider whether you are actually learning or if you are just copying me.
And if you find that you are the latter student, please pause right now and really put in some more
effort into trying this exercise on your own.
Now, you'll also notice that I've actually left the legacy version of this lecture in the course,
I think this is useful for two reasons.
Firstly, it covers topics like imbalance classes and the confusion matrix, which is unnecessary to
repeat again.
But secondly, and more importantly, I want you to notice how complex it is to use the torture text
API for a simple prediction.
It's actually surprisingly ugly.
So I want you to watch that and compare it to this one to get a real understanding for why doing things
yourself cannot only be useful, but preferable.
Keep in mind that the torture text library is not even at version one, which means it is likely to
change again in the near future.
So there are many reasons why it's simply better to avoid using it.
Learning it now is just not a good investment.
As mentioned, I've seen multiple instances where courses simply use the CARUS text module instead,
and with all that complexity you'll see that we can do the same thing here with just five very short
lines of code.
OK, so the first part of this notebook is all the same as before.
So let's assume that the code has been run.
The next step is to simply pick a random text that we want to classify.
Alternatively, you can make up your own or draw a sample from the data set.
The next step is to perform the usual preprocessing steps where we tokenized the text and then convert
it into a list of integers.
The next step is to convert our list of integers into a torch tensor, as you recall, this needs to
be NBT, where end is the number of samples and to use the sequence length since we only have one sample.
This is a one byte array.
Now that our text is in the format we need for passing it into a neural network.
The next step is to simply make the prediction using our trained model.
Note that I've also move the tensor to the GPU since our model is also on the GPU.
OK, so the final step, which doesn't really count, is a line of code, is to just print out the output.
So as you can see, we get a very large number, which means that this would be a sign to spam.
This makes sense, since if you read the above text, you can confirm that it is, in fact, a spam
message as an exercise.
Think about why this output value is not between zero and one, as you may have expected.