November 2018
Beginner to intermediate
182 pages
4h 48m
English
Let's use the model we trained to make some predictions on the test data:
test_preds = []model.eval()for x, y in tqdm(test_dl): preds = model(x) # if you're data is on the GPU, you need to move the data back to the cpu preds = preds.data.cpu().numpy() # the actual outputs of the model are logits, so we need to pass these values to the sigmoid function preds = 1 / (1 + np.exp(-preds)) test_preds.append(preds)test_preds = np.hstack(test_preds)
The entire loop is now in eval mode, which we use to lock the model weights. Alternatively, we could have set model.train(False) as well.
We iteratively take batchsize samples from the test iterator, make predictions, and append them to a list. At the end, we stack them.
Read now
Unlock full access