What happens to the tensor when I change its type from Float to Long
This is supposed to be a segmentation mask of an image, and it gets completely wrecked when I change it to LongTensor.
What happens to the tensor when I change its type from Float to Long
This is supposed to be a segmentation mask of an image, and it gets completely wrecked when I change it to LongTensor.
Since you are working with floating point values, you would have to be careful about transforming these values to long
, as you might lose all information.
E.g. assuming your tensor contains values in [0, 1]
converting them to long
could round all values to 0:
x = np.random.uniform(0, 1, (100, 100, 3))
plt.imshow(x) # shows valid image
plt.imshow(x.astype(np.int64)) # blank image
print(np.unique(x.astype(np.int64)))
> array([0], dtype=int64)