torchsig.transforms.transforms.CutOut¶
- class torchsig.transforms.transforms.CutOut(duration=(0.01, 0.2), cut_type: list[str] = ['zeros', 'ones', 'low_noise', 'avg_noise', 'high_noise'], **kwargs)[source]¶
Bases:
SignalTransformApplies the CutOut transform operation in the time domain.
The cut_dur input specifies how long the cut region should be, and the cut_fill input specifies what the cut region should be filled in with. Options for the cut type include: zeros, ones, low_noise, avg_noise, and high_noise. Zeros fills in the region with zeros; ones fills in the region with 1+1j samples; low_noise fills in the region with noise with -100dB power; avg_noise adds noise at power average of input data, effectively slicing/removing existing signals in the most RF realistic way of the options; and high_noise adds noise with 40dB power. If a list of multiple options are passed in, they are randomly sampled from. This transform is loosely based on “Improved Regularization of Convolutional Neural Networks with Cutout”.
- duration¶
cut_dur sets the duration of the region to cut out * If float, cut_dur is fixed at the value provided. * If list, cut_dur is any element in the list. * If tuple, cut_dur is in range of (tuple[0], tuple[1]).
- duration_distribution¶
Random draw from duration distribution.
- cut_type¶
cut_fill sets the type of data to fill in the cut region with from the options: zeros, ones, low_noise, avg_noise, and high_noise * If list, cut_fill is any element in the list. * If str, cut_fill is fixed at the method provided.
- cut_type_distribution¶
Random draw from cut_type distribution.
Methods
Add parent Seedable object and set up RNGs accordingly.
Create distribution function with proper seeding.
Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.
Seed number generators with given seed.
Initialize torch and numpy number generators, and update its children.
Update numpy and torch number generators with parent seed.
- __init__(duration=(0.01, 0.2), cut_type: list[str] = ['zeros', 'ones', 'low_noise', 'avg_noise', 'high_noise'], **kwargs)[source]¶
Initialize the CutOut transform.
- Parameters:
duration – cut_dur sets the duration of the region to cut out. Defaults to (0.01, 0.2).
cut_type – cut_fill sets the type of data to fill in the cut region with. Defaults to [“zeros”, “ones”, “low_noise”, “avg_noise”, “high_noise”].
**kwargs – Additional keyword arguments passed to the parent class.
- __call__(signal: Signal) Signal¶
Validates signal, performs transform, updates bookeeping, (optionally) enforces data type.
- Parameters:
signal – Signal to be transformed.
- Returns:
Transformed signal.
- __repr__() str¶
Transform string representation.
Should be able to recreate class from this string.
- Returns:
Transform representation.
- __str__() str¶
String representation of the transform.
- Returns:
String representation of the transform.
- add_parent(parent: Seedable, register: bool = True) None¶
Add parent Seedable object and set up RNGs accordingly.
- Parameters:
parent – Parent Seedable object to add.
register – If True (default), add self to parent.children so that future seed propagation reaches this object. Pass False for transient objects (e.g. per-sample Signal instances) that only need the parent link for metadata/RNG access during their lifetime but must not accumulate in the parent’s child list, which would otherwise cause unbounded memory growth.
- get_distribution(params: list | tuple | float, scaling: str = 'linear') Distribution¶
Create distribution function with proper seeding.
- Parameters:
params – Parameters for distribution.
scaling – Scaling param for distribution. Defaults to ‘linear’.
- Returns:
Distribution function, seeded.
- Return type: