torch.randn_like(images) will try to sample random values from a gaussian distribution using the passed images properties such as its dtype. I don’t think it would make a lot of sense to try to use unit8 for this sampling operation, so you might either want to transform the dtype of images to a floating point type or use another sampling (e.g. torch.randint).