Individual Tests

I’ve watched all the lectures up to lesson 12 and spent a good amount of time on each notebook, but one thing that constantly confounds me is how to run individual tests.

Is there some resource or set of examples where people have run a bunch of single tests on their models and seen the output? Occasionally, like in Lesson 4, Jeremy shows how to give the model some data and how to get data back, but it doesn’t generalize well to other types of models or architectures. For example, although he shows how to give and get data with the hand-built LSTM models, I can’t figure out how to do it with other model types.

Ideally I’d like to just see a bunch of examples of people manually putting data in and getting data back with the various APIs. Does this exist?

In general you need to get the data you want to predict on into the same format as the data your model was trained on.

For text you need to tokenize and numericalize.
For images you need to normalize and scale the image the same as the training image.

Once your data is in the right format, you can put it into a pytorch vector and pass it directly to the model.

One way I’ve found that makes it easy to get predictions on a lot of new data is to create a new model data object with the data I want predictions for, and use learner.predict_dl to pass the new dataloader directly to the model. This is particularly good for images, as creating the new dataloader handles normalization and scaling of the images for you.