For some reasons, I still have to work on PyTorch 0.3.1.
For example, I have a batch of data. Its size = [16, 3, 100, 200]. Actually, they are RGB images.
I want to shuffle the pixels of an image. It doesn’t matter if I shuffle all the images the same way or not. I just need to randomly shuffle the pixels when training on each batch.
I just shuffle pixels among the same image on the same channel. Change the pixel position, but don’t change its RGB value.
for idx in range(batch_size): data[idx, :, :, :] = shuffle_an_image(data[idx, :, :, :])
Also, the image has an mask. I have to permute the mask the same way.
The data type is Variable. Actually, I only use shuffled images when computing loss function.
I hope someone can help me.