librosax.layers.DropStripes¶
- class DropStripes(*args: Any, **kwargs: Any)[source]¶
A module that randomly drops stripes (time or frequency bands) from a spectrogram.
This module is used for data augmentation in audio tasks by randomly masking contiguous blocks along either the time or frequency dimension. Each stripe is a rectangular mask that spans the entire height (for time masking) or width (for frequency masking) of the spectrogram.
- Variables:
axis – Axis along which to drop stripes. -
axis=2: Drop vertical stripes (time masking) - masks entire frequency range for selected time frames -axis=3: Drop horizontal stripes (frequency masking) - masks entire time range for selected frequency binsdrop_width – Maximum width of each stripe to drop. Each stripe will have a random width between 0 and this value. For time masking, this is the maximum number of consecutive time frames to mask. For frequency masking, this is the maximum number of consecutive frequency bins to mask.
stripes_num – Number of stripes to drop. Each stripe is independently positioned and sized. Multiple stripes may overlap.
deterministic – If
True, no dropping is performed. Default isFalse.rng_collection – The rng collection name to use when requesting an rng key. Default is
"dropout".rngs – Random number generator key for generating random masks.
- Implementation Details:
Each stripe has a random width sampled from [0, drop_width)
Each stripe has a random starting position that ensures it fits within bounds
Stripes are applied multiplicatively (regions set to 0)
Each item in a batch receives different random stripes
Overlapping stripes do not create additional masking effect
- __init__(axis: int, drop_width: int, stripes_num: int, deterministic: bool = False, rng_collection: str = 'dropout', rngs: Rngs | RngStream | None = None)[source]¶
Methods
__init__(axis, drop_width, stripes_num[, ...])eval(**attributes)Sets the Module to evaluation mode.
iter_children()Iterates over all children
Module's of the current Module.iter_modules()Recursively iterates over all nested
Module's of the current Module, including the current Module.perturb(name, value[, variable_type])Add an zero-value variable ("perturbation") to the intermediate value.
set_attributes(*filters[, raise_if_not_found])Sets the attributes of nested Modules including the current Module.
sow(variable_type, name, value[, reduce_fn, ...])sow()can be used to collect intermediate values without the overhead of explicitly passing a container through each Module call.train(**attributes)Sets the Module to training mode.