Thanks a lot! That’s very helpful!
However, I can’t use torchvision.transforms. Because there is no joint transformation of multiple images.
For example, I have an input_rgb_image, a mask image, and a gt_image. Their pixels must be shuffled the same way.
I implement it like this (regard it as persuade code),
        size = rgb_image.size()
        perm = torch.randperm(size[2] * size[3])
        for idx in range(size[0]):
            for cn in range(size[1]):
                rgb_image[idx, cn, :, :] =  rgb_image[idx, cn, :, :].view(-1)[perm].view(size[2], size[3])
                mask[idx, cn, :, :] =  mask[idx, cn, :, :].view(-1)[perm].view(size[2], size[3])
                gt_image[idx, cn, :, :] =  gt_image[idx, cn, :, :].view(-1)[perm].view(size[2], size[3])

Is there any way to delete the two for  loops?
for  loop is very slow, right?