class pumpp.sampler.VariableLengthSampler(n_samples, min_duration, max_duration, *ops, **kwargs)[source]

Sample random patches like a Sampler, but allow for output patches to be less than the target duration when the data is too short.

See also


n_samples : int or None

the number of samples to generate. If None, generate indefinitely.

min_duration : int > 0

The minimum duration (in frames) of each sample

max_duration : int > 0

the maximum duration (in frames) of each sample

random_state : None, int, or np.random.RandomState

If int, random_state is the seed used by the random number generator;

If RandomState instance, random_state is the random number generator;

If None, the random number generator is the RandomState instance used by np.random.

ops : array of pumpp.feature.FeatureExtractor or pumpp.task.BaseTaskTransformer

The operators to include when sampling data.

__init__(n_samples, min_duration, max_duration, *ops, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.


__init__(n_samples, min_duration, …) Initialize self.
add(operator) Add an operator to the Slicer
crop(data) Crop a data dictionary down to its common time
data_duration(data) Compute the valid data duration of a dict
indices(data) Generate patch indices
sample(data, interval) Sample a patch from the data object