speechbrain.nnet.complex_networks.c_ops module¶
- This library implements different operations needed by complex-
valued architectures. This work is inspired by: “Deep Complex Networks” from Trabelsi C. et al.
- Authors
Titouan Parcollet 2020
Summary¶
Functions:
Applies the weight initialization function given to the parameters. |
|
Applies the weight initialization function given to the parameters. |
|
Check the complex-valued shape for a linear layer. |
|
Applies a complex convolution to the incoming data. |
|
Returns a matrice of complex numbers initialized as described in: “Deep Complex Networks”, Trabelsi C. |
|
Applies a complex linear transformation to the incoming data. |
|
Returns the conjugate (z = r - xi) of the input complex numbers. |
|
Returns the imaginary components of the complex-valued input. |
|
Returns the real components of the complex-valued input. |
|
Performs torch.mean over multiple dimensions of input. |
|
Returns a matrice of unitary complex numbers. |
Reference¶
-
speechbrain.nnet.complex_networks.c_ops.
check_complex_input
(input_shape)[source]¶ Check the complex-valued shape for a linear layer.
- Parameters
input_shape (tuple) – Expected shape of the input.
-
speechbrain.nnet.complex_networks.c_ops.
get_real
(input, input_type='linear', channels_axis=1)[source]¶ Returns the real components of the complex-valued input.
- Parameters
input (torch.Tensor) – Input tensor.
input_type (str,) – (convolution, linear) (default “linear”)
channels_axis (int.) – Default 1.
-
speechbrain.nnet.complex_networks.c_ops.
get_imag
(input, input_type='linear', channels_axis=1)[source]¶ Returns the imaginary components of the complex-valued input.
- Parameters
input (torch.Tensor) – Input tensor.
input_type (str,) – (convolution, linear) (default “linear”)
channels_axis (int.) – Default 1.
-
speechbrain.nnet.complex_networks.c_ops.
get_conjugate
(input, input_type='linear', channels_axis=1)[source]¶ Returns the conjugate (z = r - xi) of the input complex numbers.
- Parameters
input (torch.Tensor) – Input tensor
input_type (str,) – (convolution, linear) (default “linear”)
channels_axis (int.) – Default 1.
-
speechbrain.nnet.complex_networks.c_ops.
complex_linear_op
(input, real_weight, imag_weight, bias)[source]¶ Applies a complex linear transformation to the incoming data.
- Parameters
input (torch.Tensor) – Complex input tensor to be transformed.
real_weight (torch.Parameter) – Real part of the quaternion weight matrix of this layer.
imag_weight (torch.Parameter) – First imaginary part of the quaternion weight matrix of this layer.
bias (torch.Parameter) –
-
speechbrain.nnet.complex_networks.c_ops.
complex_conv_op
(input, real_weight, imag_weight, bias, stride, padding, dilation, conv1d)[source]¶ Applies a complex convolution to the incoming data.
- Parameters
input (torch.Tensor) – Complex input tensor to be transformed.
conv1d (bool) – If true, a 1D convolution operation will be applied. Otherwise, a 2D convolution is called.
real_weight (torch.Parameter) – Real part of the quaternion weight matrix of this layer.
imag_weight (torch.Parameter) – First imaginary part of the quaternion weight matrix of this layer.
bias (torch.Parameter) –
stride (int) – Stride factor of the convolutional filters.
padding (int) – Amount of padding. See torch.nn documentation for more information.
dilation (int) – Dilation factor of the convolutional filters.
-
speechbrain.nnet.complex_networks.c_ops.
unitary_init
(in_features, out_features, kernel_size=None, criterion='glorot')[source]¶ Returns a matrice of unitary complex numbers.
-
speechbrain.nnet.complex_networks.c_ops.
complex_init
(in_features, out_features, kernel_size=None, criterion='glorot')[source]¶ Returns a matrice of complex numbers initialized as described in: “Deep Complex Networks”, Trabelsi C. et al.
-
speechbrain.nnet.complex_networks.c_ops.
affect_init
(real_weight, imag_weight, init_func, criterion)[source]¶ Applies the weight initialization function given to the parameters.
- Parameters
real_weight (torch.Parameters) –
imag_weight (torch.Parameters) –
init_func (function) – (unitary_init, complex_init)
criterion (str) – (glorot, he)