espnet2.enh.layers.complexnn.ComplexConvTranspose2d
espnet2.enh.layers.complexnn.ComplexConvTranspose2d
class espnet2.enh.layers.complexnn.ComplexConvTranspose2d(in_channels, out_channels, kernel_size=(1, 1), stride=(1, 1), padding=(0, 0), output_padding=(0, 0), causal=False, complex_axis=1, groups=1)
Bases: Module
ComplexConvTranspose2d.
This module performs a 2D transposed convolution operation on complex inputs, which are expected to be represented as two channels: real and imaginary. The input channels and output channels are expected to be double the size (real + imag).
Attributes: : in_channels (int): Number of input channels (real + imag). out_channels (int): Number of output channels (real + imag). kernel_size (tuple): Size of the convolution kernel. stride (tuple): Stride of the convolution. padding (tuple): Padding added to both sides of the input. output_padding (tuple): Additional size added to one side of the <br/>
output shape. <br/> causal (bool): If True, pads the left side of the time dimension : for causal convolutions. <br/> complex_axis (int): The axis along which to split the complex : input into real and imaginary parts. <br/> groups (int): Number of groups for grouped convolution.
Args: : in_channels (int): Number of input channels (real + imag). out_channels (int): Number of output channels (real + imag). kernel_size (tuple, optional): Size of the convolution kernel. stride (tuple, optional): Stride of the convolution. padding (tuple, optional): Padding added to both sides of the input. output_padding (tuple, optional): Additional size added to one side <br/>
of the output shape. <br/> causal (bool, optional): If True, pads the left side of the time : dimension for causal convolutions. <br/> complex_axis (int, optional): The axis along which to split the : complex input into real and imaginary parts. <br/> groups (int, optional): Number of groups for grouped convolution.
Returns: : torch.Tensor: The output tensor containing concatenated real and : imaginary parts after transposed convolution.
Examples: : ```python
conv_transpose = ComplexConvTranspose2d( ... in_channels=4, out_channels=8, kernel_size=(3, 3), stride=(2, 2) ... ) input_tensor = torch.randn(1, 8, 10, 10) # Batch size 1, 8 channels output = conv_transpose(input_tensor) output.shape torch.Size([1, 16, 20, 20]) # Output shape after transposed conv
Note: : The input tensor must be structured such that the real and imaginary parts are split along the complex axis.
ComplexConvTranspose2d.
in_channels: real+imag out_channels: real+imag
forward(inputs)
Applies the complex transposed convolution to the input tensor.
This method takes an input tensor, splits it into real and imaginary parts, and then applies the complex transposed convolution operation to these parts separately. The results are then combined to form the output tensor.
- Parameters:inputs (torch.Tensor or tuple or list) – The input tensor containing real and imaginary components, which can be in the form of a single tensor or a tuple/list of two tensors.
- Returns: A tensor that contains the output of the complex transposed convolution, with the same format as the input (real and imaginary parts concatenated).
- Return type: torch.Tensor
Examples
>>> import torch
>>> conv_transpose = ComplexConvTranspose2d(4, 8, kernel_size=(3, 3))
>>> input_tensor = torch.randn(1, 8, 10, 10) # Batch size of 1
>>> output = conv_transpose(input_tensor)
>>> output.shape
torch.Size([1, 16, 12, 12]) # Adjusted dimensions after transposed conv
NOTE
The input tensor is expected to be of shape [B, C, H, W] where B is the batch size, C is the number of channels (real + imaginary), H is the height, and W is the width.
- Raises:
- ValueError – If the input tensor does not have the correct number of
- channels (must be even, as they represent real and imaginary parts**)****.** –