torchtext.__version__ '0.3.1'
test_preds = []
for x, y in tqdm.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()
preds = preds.data.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)
In my experiment, the correct one should be np.vstack .
The elements of list test_preds are type ndarrays with shape (batches, features=6) and the batches of the last element might be different from others if total number of samples can not be divided by batch_size
torchtext.__version__'0.3.1'In my experiment, the correct one should be
np.vstack.The elements of list
test_predsare type ndarrays with shape(batches, features=6)and thebatchesof the last element might be different from others if total number of samples can not be divided bybatch_size