espnet2.enh.layers.dcunet.FeatureMapDense
espnet2.enh.layers.dcunet.FeatureMapDense
class espnet2.enh.layers.dcunet.FeatureMapDense(input_dim, output_dim, complex_valued=False)
Bases: Module
A fully connected layer that reshapes outputs to feature maps.
This layer is designed to be used in the context of complex-valued neural networks, where it applies a dense linear transformation to the input and reshapes the output to add two additional dimensions for feature maps. It utilizes the ComplexLinear layer to handle complex-valued inputs.
complex_valued
Indicates if the layer processes complex-valued inputs.
- Type: bool
dense
The underlying dense layer that performs the linear transformation.
Type:ComplexLinear
Parameters:
- input_dim (int) – The number of input features.
- output_dim (int) – The number of output features.
- complex_valued (bool) – Whether the layer should support complex values. Defaults to False.
Returns: The reshaped output tensor with added dimensions for feature maps.
Return type: Tensor
####### Examples
>>> layer = FeatureMapDense(input_dim=128, output_dim=64, complex_valued=True)
>>> input_tensor = torch.randn(10, 128) + 1j * torch.randn(10, 128)
>>> output_tensor = layer(input_tensor)
>>> output_tensor.shape
torch.Size([10, 64, 1, 1])
NOTE
This layer is primarily intended for use in complex-valued models, such as those used for audio signal processing or speech enhancement.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)
A fully connected layer that reshapes outputs to feature maps.
This layer takes an input tensor and transforms it into a shape suitable for subsequent operations in a neural network. It is designed to handle both real and complex-valued inputs, depending on the configuration.
complex_valued
Indicates whether the layer operates on complex numbers.
- Type: bool
dense
A linear layer that handles the transformation of input dimensions.
Type:ComplexLinear
Parameters:
- input_dim (int) – The number of input features.
- output_dim (int) – The number of output features.
- complex_valued (bool , optional) – If True, the layer will handle complex inputs. Defaults to False.
Returns: The reshaped output tensor.
Return type: Tensor
####### Examples
>>> import torch
>>> layer = FeatureMapDense(input_dim=128, output_dim=256)
>>> input_tensor = torch.randn(10, 128) # Batch of 10 samples
>>> output_tensor = layer(input_tensor)
>>> print(output_tensor.shape) # Should print (10, 256, 1, 1)
NOTE
The output tensor will have two additional dimensions (1, 1) added to facilitate reshaping into feature maps for subsequent layers.