Converting Tensor from Float to Byte

Is there a way to convert FloatTensor to ByteTensor?

I’m trying to do the equivalent of: np.random.uniform(size=images.shape) < images.
I create a new Tensor and initialize it with nn.init.uniform, then perform the comparison with the ByteTensor (images), the result is still a FloatTensor. How do I convert this to ByteTensor?

If you have a tensor t just do t.byte()

5 Likes

thank you , I was just looking for some solution for tensor format converting.