Applying random transformations with probability p=1

Hi all,

Do applying Random Transformation (flip, crop rotate or any etc.) with p=1 means it is applied to all tensors/PIL images that are passed?

OR

it is like, if p=1 then any randomly chosen PIL image/Tensor will be be transformed because it is now selected and those skipped tensors/PIL images will be preserved as they were before?

I am confused in this command, please help me out.

Thanks in advance.

dear @ptrblck, please guide me through this.

The probability p will be used to determine, if the current image passed through the transformation will be transformed or not as seen e.g. here.

1 Like

why not all Random transforms have probability (p) argument?
For example if I use RandomRotation(10), does this mean p=1 is explicitly assumed and rotation will be applied between -10 to 10 degrees to ALL images?

Yes, RandomRotation will transform all inputs and uses a uniform probability to sample the angle in the specified range. Random*Flip uses the passed probability to apply the flipping or to keep the original image, so both are using a probability in a similar sense where the former is uniform and the latter is binary. If you want to randomly apply a random transformation (such as RandomRotation), you could check transforms.RandomApply.

1 Like