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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
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
69 70 71 72 73 74 75 76 77 78 79 80 |
|
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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
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
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
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
148 149 150 151 152 153 154 155 156 157 158 |
|
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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
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
17 18 19 20 21 22 23 24 25 26 |
|
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. |
Source code in models/enhancer/gaussian_diffusion/layers.py
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 |
|