Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
nidl.volume.transforms.augmentation.RandomErasing¶
- class nidl.volume.transforms.augmentation.RandomErasing(scale=(0.02, 0.33), ratio=(1.0, 3.0), num_iterations=1, value=0.0, inplace=False, **kwargs)[source]¶
Bases:
VolumeTransformRandomly erases boxes in a 3d volume.
Randomly selects one or multiple boxes in input data and erases their values (i.e. random erasing [1], very similar to cutout [2] but with arbitrary aspect ratio). It is an extension of torchvision.transforms.RandomErasing to the 3d case and it can eventually erase multiple random boxes. It handles
numpy.ndarrayortorch.Tensoras input and returns a consistent output (same type and shape).- Parameters:
- scale: tuple of (float, float), default=(0.02, 0.33)
Range of proportion of erased area against input data.
- ratio: tuple of (float, float), default=(1.0, 3.0)
Range of aspect ratio of erased area (min, max).
- num_iterations: int, default=1
Number of erased areas.
- value: float, “mean” or “random”, default=0.0
Erasing value. If “random”, erases each voxel with random values normally distributed. If “mean”, replaces each voxel with the mean value of the erased area, preserving the global statistics.
- inplace: bool, default=False
If true, makes the transformation inplace, i.e. it modifies the input data directly.
- kwargs: dict
Additional keyword.
Notes
In 3d, we define the “aspect ratio” as the ratio between each dimension size relatively to their geometric mean. It is a simple generalization from 2d to nd and we don’t particularize any dimension. The aspect ratio is sampled three times for a 3d volume (one for each dimension).
References
[1]Zhong, Z., Zheng, L., Kang, G., Li, S., & Yang, Y. (2020). Random Erasing Data Augmentation. In AAAI Conference on Artificial Intelligence. https://arxiv.org/abs/1708.04896
[2]DeVries, T., & Taylor, G. W. (2017). Improved Regularization of Convolutional Neural Networks with Cutout https://arxiv.org/abs/1708.04552
or
. Erased boxes are equal the same across channels.