speechbrain.nnet.complex_networks.c_CNN module
Library implementing complex-valued convolutional neural networks.
- Authors
Titouan Parcollet 2020
Summary
Classes:
This function implements complex-valued 1d convolution. |
|
This function implements complex-valued 1d convolution. |
Reference
- class speechbrain.nnet.complex_networks.c_CNN.CConv1d(out_channels, kernel_size, input_shape, stride=1, dilation=1, padding='same', groups=1, bias=True, padding_mode='reflect', init_criterion='glorot', weight_init='complex')[source]
Bases:
Module
This function implements complex-valued 1d convolution.
- Parameters
out_channels (int) – Number of output channels. Please note that these are complex-valued neurons. If 256 channels are specified, the output dimension will be 512.
kernel_size (int) – Kernel size of the convolutional filters.
stride (int, optional) – Stride factor of the convolutional filters (default 1).
dilation (int, optional) – Dilation factor of the convolutional filters (default 1).
padding (str, optional) – (same, valid, causal). If “valid”, no padding is performed. If “same” and stride is 1, output shape is same as input shape. “causal” results in causal (dilated) convolutions. (default “same”)
padding_mode (str, optional) – This flag specifies the type of padding. See torch.nn documentation for more information (default “reflect”).
groups (int, optional) – This option specifies the convolutional groups. See torch.nn documentation for more information (default 1).
bias (bool, optional) – If True, the additive bias b is adopted (default True).
init_criterion (str, optional) – (glorot, he). This parameter controls the initialization criterion of the weights. It is combined with weights_init to build the initialization method of the complex-valued weights. (default “glorot”)
weight_init (str, optional) – (complex, unitary). This parameter defines the initialization procedure of the complex-valued weights. “complex” will generate random complex-valued weights following the init_criterion and the complex polar form. “unitary” will normalize the weights to lie on the unit circle. (default “complex”) More details in: “Deep Complex Networks”, Trabelsi C. et al.
Example
>>> inp_tensor = torch.rand([10, 16, 30]) >>> cnn_1d = CConv1d( ... input_shape=inp_tensor.shape, out_channels=12, kernel_size=5 ... ) >>> out_tensor = cnn_1d(inp_tensor) >>> out_tensor.shape torch.Size([10, 16, 24])
- forward(x)[source]
Returns the output of the convolution.
- Parameters
x (torch.Tensor) – (batch, time, channel). Input to convolve. 3d or 4d tensors are expected.
- class speechbrain.nnet.complex_networks.c_CNN.CConv2d(out_channels, kernel_size, input_shape, stride=1, dilation=1, padding='same', groups=1, bias=True, padding_mode='reflect', init_criterion='glorot', weight_init='complex')[source]
Bases:
Module
This function implements complex-valued 1d convolution.
- Parameters
out_channels (int) – Number of output channels. Please note that these are complex-valued neurons. If 256 channels are specified, the output dimension will be 512.
kernel_size (int) – Kernel size of the convolutional filters.
stride (int, optional) – Stride factor of the convolutional filters (default 1).
dilation (int, optional) – Dilation factor of the convolutional filters (default 1).
padding (str, optional) – (same, valid, causal). If “valid”, no padding is performed. If “same” and stride is 1, output shape is same as input shape. “causal” results in causal (dilated) convolutions. (default “same”)
padding_mode (str, optional) – This flag specifies the type of padding (default “reflect”). See torch.nn documentation for more information.
groups (int, optional) – This option specifies the convolutional groups (default 1). See torch.nn documentation for more information.
bias (bool, optional) – If True, the additive bias b is adopted (default True).
init_criterion (str , optional) – (glorot, he). This parameter controls the initialization criterion of the weights (default “glorot”). It is combined with weights_init to build the initialization method of the complex-valued weights.
weight_init (str, optional) – (complex, unitary). This parameter defines the initialization procedure of the complex-valued weights (default complex). “complex” will generate random complex-valued weights following the init_criterion and the complex polar form. “unitary” will normalize the weights to lie on the unit circle. More details in: “Deep Complex Networks”, Trabelsi C. et al.
Example
>>> inp_tensor = torch.rand([10, 16, 30, 30]) >>> cnn_2d = CConv2d( ... input_shape=inp_tensor.shape, out_channels=12, kernel_size=5 ... ) >>> out_tensor = cnn_2d(inp_tensor) >>> out_tensor.shape torch.Size([10, 16, 30, 24])
- forward(x, init_params=False)[source]
Returns the output of the convolution.
- Parameters
x (torch.Tensor) – (batch, time, feature, channels). Input to convolve. 3d or 4d tensors are expected.