vak.transforms.transforms.PadToWindow#

class vak.transforms.transforms.PadToWindow(window_size, padval=0.0, return_padding_mask=True)[source]#

Bases: object

pad a 1d or 2d array so that it can be reshaped into consecutive windows of specified size

Parameters:
  • arr (numpy.ndarray) – with 1 or 2 dimensions, e.g. a vector of labeled timebins or a spectrogram.

  • window_size (int) – width of window in number of elements.

  • padval (float) – value to pad with. Added to end of array, the β€œright side” if 2-dimensional.

  • return_padding_mask (bool) – if True, return a boolean vector to use for cropping back down to size before padding. padding_mask has size equal to width of padded array, i.e. original size plus padding at the end, and has values of 1 where columns in padded are from the original array, and values of 0 where columns were added for padding.

Returns:

  • padded (numpy.ndarray) – padded with padval

  • padding_mask (np.bool) – has size equal to width of padded, i.e. original size plus padding at the end. Has values of 1 where columns in padded are from the original array, and values of 0 where columns were added for padding. Only returned if return_padding_mask is True.

__init__(window_size, padval=0.0, return_padding_mask=True)[source]#

Methods

__init__(window_size[, padval, ...])