Layers
ConvNorm
Bases: Module
1D Convolution with optional batch normalization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
kernel_size |
int
|
Size of the convolving kernel. Defaults to 1. |
1
|
stride |
int
|
Stride of the convolution. Defaults to 1. |
1
|
padding |
int
|
Zero-padding added to both sides of the input. Defaults to None. |
None
|
dilation |
int
|
Spacing between kernel elements. Defaults to 1. |
1
|
bias |
bool
|
If True, adds a learnable bias to the output. Defaults to True. |
True
|
Source code in models/enhancer/gaussian_diffusion/layers.py
forward(signal)
Forward pass through the convolutional layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal |
Tensor
|
Input signal tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Output tensor after convolution. |
Source code in models/enhancer/gaussian_diffusion/layers.py
DiffusionEmbedding
Bases: Module
Diffusion Step Embedding.
This module generates diffusion step embeddings for the given input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d_denoiser |
int
|
Dimension of the denoiser. |
required |
Attributes:
Name | Type | Description |
---|---|---|
dim |
int
|
Dimension of the diffusion step embedding. |
Source code in models/enhancer/gaussian_diffusion/layers.py
forward(x)
Forward pass through the DiffusionEmbedding module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
Input tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Diffusion step embeddings. |
Source code in models/enhancer/gaussian_diffusion/layers.py
LinearNorm
Bases: Module
LinearNorm Projection.
This module performs a linear projection with optional bias.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_features |
int
|
Number of input features. |
required |
out_features |
int
|
Number of output features. |
required |
bias |
bool
|
If True, adds a learnable bias to the output. Default is False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
linear |
Linear
|
Linear transformation module. |
Source code in models/enhancer/gaussian_diffusion/layers.py
forward(x)
Forward pass through the LinearNorm module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
Input tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Output tensor after linear projection. |
Source code in models/enhancer/gaussian_diffusion/layers.py
Mish
Bases: Module
Applies the Mish activation function.
Mish is a smooth, non-monotonic function that attempts to mitigate the problems of dying ReLU units in deep neural networks.
Source code in models/enhancer/gaussian_diffusion/layers.py
forward(x)
Forward pass of the Mish activation function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
Input tensor. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Output tensor after applying Mish activation. |
Source code in models/enhancer/gaussian_diffusion/layers.py
ResidualBlock
Bases: Module
Residual Block.
This module defines a residual block used in a neural network architecture. It consists of several convolutional and linear projections followed by nonlinear activations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d_encoder |
int
|
Dimension of the encoder output. |
required |
residual_channels |
int
|
Number of channels in the residual block. |
required |
dropout |
float
|
Dropout probability. |
required |
d_spk_prj |
int
|
Dimension of the speaker projection. |
required |
multi_speaker |
bool
|
Flag indicating if the model is trained with multiple speakers. Defaults to True. |
True
|
Attributes:
Name | Type | Description |
---|---|---|
multi_speaker |
bool
|
Flag indicating if the model is trained with multiple speakers. |
conv_layer |
ConvNorm
|
Convolutional layer in the residual block. |
diffusion_projection |
LinearNorm
|
Linear projection for the diffusion step. |
speaker_projection |
LinearNorm
|
Linear projection for the speaker embedding. |
conditioner_projection |
ConvNorm
|
Convolutional projection for the conditioner. |
output_projection |
ConvNorm
|
Convolutional projection for the output. |
Source code in models/enhancer/gaussian_diffusion/layers.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
forward(x, conditioner, diffusion_step, speaker_emb, mask=None)
Forward pass through the ResidualBlock module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
Input tensor. |
required |
conditioner |
Tensor
|
Conditioner tensor. |
required |
diffusion_step |
Tensor
|
Diffusion step tensor. |
required |
speaker_emb |
Tensor
|
Speaker embedding tensor. |
required |
mask |
Tensor
|
Mask tensor. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[torch.Tensor, torch.Tensor]: Tuple containing the output tensor and skip tensor. |