PyTrorch Documentation mistake

Hi,

I believe there is a mistake in the PyTorch documentation regarding v2.RandomCrop. According to the documentation, the fill parameter can be used as follows:

  • fill (number or tuple or dict, optional) – Pixel fill value used when the padding_mode is constant. The default is 0. If a tuple of length 3, it is used to fill the R, G, B channels respectively. The fill value can also be a dictionary mapping the data type to the fill value, e.g., fill={tv_tensors.Image: 127, tv_tensors.Mask: 0} where Image will be filled with 127 and Mask will be filled with 0.

However, when I tried to use it as the documentation suggested:

transform = v2.RandomCrop(size=(800, 800), pad_if_needed=True, fill=(0, 0, 255))

I encountered the following error:

RuntimeError: The expanded size of the tensor (4) must match the existing size (3) at non-singleton dimension 0. Target sizes: [4, 103, 906]. Tensor sizes: [3, 1, 1]

But when I set the fill tuple to fill=(0, 0, 255, 150), where 150 is the alpha value, it worked.

Are you sure you are loading RGB images or do these contain an alpha channel?

Oh, it was my mistake for not noticing that my image was in 4 channels (RGBA) instead of 3 (RGB). I have changed the ImageReadMode and its work done.
Thank you very much.