asteroid.filterbanks.enc_dec module¶
-
class
asteroid.filterbanks.enc_dec.
Decoder
(filterbank, is_pinv=False, padding=0, output_padding=0)[source]¶ Bases:
asteroid.filterbanks.enc_dec._EncDec
Decoder class.
Add decoding methods to Filterbank classes. Not intended to be subclassed.
Parameters: - filterbank (
Filterbank
) – The filterbank to use as an decoder. - is_pinv (bool) – Whether to be the pseudo inverse of filterbank.
- padding (int) – Zero-padding added to both sides of the input.
- output_padding (int) – Additional size added to one side of the output shape.
- Notes
- padding and output_padding arguments are directly passed to F.conv_transpose1d.
-
forward
(spec)[source]¶ Applies transposed convolution to a TF representation.
This is equivalent to overlap-add.
Parameters: spec ( torch.Tensor
) – 3D or 4D Tensor. The TF representation. (Output ofEncoder.forward()
).Returns: torch.Tensor
– The corresponding time domain signal.
- filterbank (
-
class
asteroid.filterbanks.enc_dec.
Encoder
(filterbank, is_pinv=False, as_conv1d=True, padding=0)[source]¶ Bases:
asteroid.filterbanks.enc_dec._EncDec
Encoder class.
Add encoding methods to Filterbank classes. Not intended to be subclassed.
Parameters: - filterbank (
Filterbank
) – The filterbank to use as an encoder. - is_pinv (bool) – Whether to be the pseudo inverse of filterbank.
- as_conv1d (bool) – Whether to behave like nn.Conv1d. If True (default), forwarding input with shape (batch, 1, time) will output a tensor of shape (batch, freq, conv_time). If False, will output a tensor of shape (batch, 1, freq, conv_time).
- padding (int) – Zero-padding added to both sides of the input.
-
forward
(waveform)[source]¶ Convolve input waveform with the filters from a filterbank. :param waveform: any tensor with samples along the
last dimension. The waveform representation with and batch/channel etc.. dimension.Returns: torch.Tensor
– The corresponding TF domain signal.- Shapes:
>>> (time, ) --> (freq, conv_time) >>> (batch, time) --> (batch, freq, conv_time) # Avoid >>> if as_conv1d: >>> (batch, 1, time) --> (batch, freq, conv_time) >>> (batch, chan, time) --> (batch, chan, freq, conv_time) >>> else: >>> (batch, chan, time) --> (batch, chan, freq, conv_time) >>> (batch, any, dim, time) --> (batch, any, dim, freq, conv_time)
-
classmethod
pinv_of
(filterbank, **kwargs)[source]¶ Returns an
Encoder
, pseudo inverse of aFilterbank
orDecoder
.
- filterbank (
-
class
asteroid.filterbanks.enc_dec.
Filterbank
(n_filters, kernel_size, stride=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Base Filterbank class. Each subclass has to implement a filters property.
Parameters: Variables: n_feats_out (int) – Number of output filters.
-
filters
¶ Abstract method for filters.
-