ml4gw.transforms.spectrogram

Classes

MultiResolutionSpectrogram(kernel_length, ...)

Create a batch of multi-resolution spectrograms from a batch of timeseries.

class ml4gw.transforms.spectrogram.MultiResolutionSpectrogram(kernel_length, sample_rate, **kwargs)

Bases: Module

Create a batch of multi-resolution spectrograms from a batch of timeseries. Input is expected to have the shape (B, C, T), where B is the number of batches, C is the number of channels, and T is the number of time samples.

For each timeseries, calculate multiple normalized spectrograms based on the Spectrogram kwargs given. Combine the spectrograms by taking the maximum value from the nearest time-frequncy bin.

If the largest number of time bins among the spectrograms is N and the largest number of frequency bins is M, the output will have dimensions (B, C, M, N)

Parameters:
  • kernel_length (float) -- The length in seconds of the time dimension of the tensor that will be turned into a spectrogram

  • sample_rate (float) -- The sample rate of the timeseries in Hz

  • **kwargs -- Arguments passed in kwargs will used to create torchaudio.transforms.Spectrogram (see documentation). Each argument should be a list of values. Any list of length greater than 1 should be the same length

forward(X)

Calculate spectrograms of the input tensor and combine them into a single spectrogram

Parameters:

X (Float[Tensor, 'batch channel time']) -- Batch of multichannel timeseries which will be used to calculate the multi-resolution spectrogram. Should have the shape (B, C, T), where B is the number of batches, C is the number of channels, and T is the number of time samples.

Return type:

Float[Tensor, 'batch channel frequency time']