vak.transforms.transforms.StandardizeSpect#

class vak.transforms.transforms.StandardizeSpect(mean_freqs=None, std_freqs=None, non_zero_std=None)[source]#

Bases: object

transform that standardizes spectrograms so they are all on the same scale, by subtracting off the mean and dividing by the standard deviation from a β€˜fit’ set of spectrograms.

mean_freqs#

mean values for each frequency bin across the fit set of spectrograms

Type:

numpy.ndarray

std_freqs#

standard deviation for each frequency bin across the fit set of spectrograms

Type:

numpy.ndarray

non_zero_std#

boolean, indicates where std_freqs has non-zero values. Used to avoid divide-by-zero errors.

Type:

numpy.ndarray

__init__(mean_freqs=None, std_freqs=None, non_zero_std=None)[source]#

initialize a new StandardizeSpect instance

Parameters:
  • mean_freqs (numpy.ndarray) – vector of mean values for each frequency bin across the fit set of spectrograms

  • std_freqs (numpy.ndarray) – vector of standard deviations for each frequency bin across the fit set of spectrograms

  • non_zero_std (numpy.ndarray) – boolean, indicates where std_freqs has non-zero values. Used to avoid divide-by-zero errors.

Methods

__init__([mean_freqs, std_freqs, non_zero_std])

initialize a new StandardizeSpect instance

fit(spect)

Fit a StandardizeSpect instance.

fit_dataset_path(dataset_path[, split, subset])

Returns a StandardizeSpect instance that is fit to a split from a dataset, given the path to that dataset and the name of the split.

classmethod fit(spect)[source]#

Fit a StandardizeSpect instance.

Parameters:

spect (numpy.ndarray) – with dimensions (frequency bins, time bins)

Notes

Input should be spectrogram. Fit function finds the mean and standard deviation of each frequency bin, which are used by transform method to scale other spectrograms.

classmethod fit_dataset_path(dataset_path, split='train', subset: str | None = None)[source]#

Returns a StandardizeSpect instance that is fit to a split from a dataset, given the path to that dataset and the name of the split.

Parameters:
  • dataset_path (str or pathlib.Path) – Path to a dataset.

  • split (str) – Name of split from dataset to fit.

Returns:

standardize_spect – Instance that has been fit to input data from split.

Return type:

StandardizeSpect