@wgpubs thanks for the clarification. Your suggestion makes sense to me but I’m still having trouble:
x, y = next(iter(trn_dl))
print(x.size(), x.type(), y.size(), y.type())
returns:
torch.Size([482, 24]) torch.cuda.LongTensor torch.Size([24]) torch.cuda.LongTensor
Every iteration of trn_dl
returns a x
pytorch long tensor of torch.Size([ N, 24])
which I confirmed is what the pytorch model is expecting.
I also used the same code as the in the fast.ai predict_array
function and was able to confirm that the resulting data type and form is correct:
to_gpu(V(T(x))))
returns:
torch.cuda.LongTensor of size 129x24 (GPU 0)
When I try the prediction:
learn.model.eval()
to_np(learn.model(to_gpu(V(T(x)))))
However, the resulting list of arrays does not seem to look like the classification I am expecting:
[array([[ 4.76909, -5.10486],
[-7.02031, 7.0272 ],
[ 4.62994, -4.94379],
...
[ 4.42602, -4.64515],
[-6.98176, 6.9849 ],
[ 6.46633, -6.73317],
[ 5.12761, -5.3733 ],
[-4.51221, 4.46605]], dtype=float32),
[array([[[-0.01546, 0.00402, 0.00247, ..., 0.21298, -0.02448, 0.00726],
[-0.01546, 0.00402, 0.00247, ..., 0.21298, -0.02448, 0.00726],
[-0.01546, 0.00402, 0.00247, ..., 0.21298, -0.02448, 0.00726],
...,
...,
[[-0.00816, 0.00167, 0.21515, ..., 0.00561, 0.06843, 0.15961],
[-0.08275, 0.03771, -0.45695, ..., 0.15028, 0.08362, 0.02582],
[ 0.0016 , 0.00206, 0.01634, ..., 0.01263, 0.03239, 0.00477],
...,
[-0.06923, 0.02377, 0.00858, ..., 0.01588, 0.04878, 0.03017],
[-0.0011 , 0.01422, -0.02462, ..., 0.02862, 0.08323, 0.00347],
[-0.06961, -0.00985, -0.23971, ..., 0.33725, 0.01575, 0.00276]],
[[ 0.00032, -0.00368, 0.00575, ..., 0.02081, 0.05157, 0.06115],
[-0.05437, 0.01115, -0.10385, ..., 0.15507, 0.10765, 0.00231],
[ 0.00508, 0.0113 , 0.01106, ..., 0.02161, 0.06531, 0.00207],
...,
[-0.01544, 0.03345, 0.02451, ..., 0.02918, 0.09549, 0.00268],
[-0.00228, 0.01238, -0.00676, ..., 0.02629, 0.04236, 0.00015],
[-0.02925, -0.00423, -0.25921, ..., 0.45078, 0.14508, -0.00259]]], dtype=float32)]]
The IMDB classification should result in an array of size two. One number for reflecting the likelihood of a POS review and another number reflecting the NEG review?