Converting numpy array to tensor on GPU

You should transform numpy arrays to PyTorch tensors with torch.from_numpy.
Otherwise some weird issues might occur.

img = torch.from_numpy(img).float().to(device)
19 Likes