conv1d
Author: Sashi Novitasari Affiliation: NAIST (-2022) Date: 2022.08
Author: Heli Qi Affiliation: NAIST Date: 2022.09
Conv1dEv
Bases: Module
A 1D convolutional layer with support for different padding modes.
Attributes:
Name | Type | Description |
---|---|---|
cutoff |
bool
|
Indicates whether the output should be cut off for the 'same' padding mode. |
causal_padding |
int
|
Additional padding required for the 'causal' padding mode. |
dilation |
int
|
The dilation rate of the convolutional layer. |
conv_lyr |
Conv1d
|
The 1D convolutional layer. |
Source code in speechain/module/prenet/conv1d.py
21 22 23 24 25 26 27 28 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 81 82 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 118 119 120 121 122 123 124 125 126 127 128 |
|
__init__(in_channels, out_channels, kernel_size, stride=1, dilation=1, padding_mode='same', bias=True, use_weight_norm=False, groups=1)
Initializes the Conv1dEv module with the specified parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_channels
|
int
|
Number of channels in the input feature. |
required |
out_channels
|
int
|
Number of channels produced by the convolution. |
required |
kernel_size
|
int
|
Size of the convolutional kernel. |
required |
stride
|
int
|
Stride of the convolution. Defaults to 1. |
1
|
dilation
|
int
|
The dilation rate of the kernel. Defaults to 1. |
1
|
padding_mode
|
str
|
Padding mode. Supported values are 'valid', 'full', 'same' and 'causal'. Defaults to 'same'. |
'same'
|
bias
|
bool
|
If True, adds a learnable bias to the output. Defaults to True. |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If an unsupported padding mode is specified. |
Source code in speechain/module/prenet/conv1d.py
forward(feat)
Performs a forward pass through the convolutional layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat
|
Tensor
|
The input feature tensor. Shape: (batch, feat_dim, feat_maxlen). |
required |
Returns:
Type | Description |
---|---|
torch.Tensor: The output tensor. Shape: (batch, out_channels, output_len). |
Source code in speechain/module/prenet/conv1d.py
Conv1dPrenet
Bases: Module
The Conv1d prenet. Usually used before the TTS encoder. This prenet is made up of two parts: 1. (mandatory) The Conv1d part contains one or more Conv1d blocks which are composed of the components below 1. (mandatory) a Conv1d layer 2. (optional) a BatchNorm1d layer 3. (optional) an activation function 4. (optional) a Dropout layer. 2. (optional) The Linear part contains one or more Linear blocks which are composed of the components below 1. (mandatory) a Linear layer 2. (optional) an activation function 3. (optional) a Dropout layer.
Reference
Neural Speech Synthesis with Transformer Network https://ojs.aaai.org/index.php/AAAI/article/view/4642/4520
Source code in speechain/module/prenet/conv1d.py
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 159 160 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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
forward(feat, feat_len)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat
|
Tensor
|
(batch, feat_maxlen, feat_dim) The input feature tensors. |
required |
feat_len
|
Tensor
|
(batch,) The length of each feature tensor. |
required |
feat, feat_len
Type | Description |
---|---|
The embedded feature vectors with their lengths. |
Source code in speechain/module/prenet/conv1d.py
module_init(feat_dim=None, conv_dims=[512, 512, 512], conv_kernel=5, conv_stride=1, conv_batchnorm=True, conv_activation='ReLU', conv_dropout=None, lnr_dims=-1, lnr_activation=None, lnr_dropout=None, zero_centered=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feat_dim
|
int
|
int The dimension of input acoustic feature tensors. Used for calculating the in_features of the first Linear layer. |
None
|
conv_dims
|
int or List[int]
|
List[int] or int The values of out_channels of each Conv1d layer. If a list of integers is given, multiple Conv1d layers will be initialized. If an integer is given, there will be only one Conv1d layer |
[512, 512, 512]
|
conv_kernel
|
int
|
int The value of kernel_size of all Conv1d layers. |
5
|
conv_stride
|
int
|
int The value of stride of all Conv1d layers. |
1
|
conv_batchnorm
|
bool
|
bool Whether a BatchNorm1d layer is added right after a Conv1d layer |
True
|
conv_activation
|
str
|
str The type of the activation function after all Conv1d layers. None means no activation function is needed. |
'ReLU'
|
conv_dropout
|
float or List[float]
|
float or List[float] The values of p rate of the Dropout layer after each Linear layer. |
None
|
lnr_dims
|
int or List[int]
|
int or List[int] The values of out_features of each Linear layer. The first value in the List represents the out_features of the first Linear layer. -1: same size as the last convolutional layer's dim |
-1
|
lnr_activation
|
str
|
str The type of the activation function after all Linear layers. None means no activation function is needed. |
None
|
lnr_dropout
|
int or List[int]
|
float or List[float] The values of p rate of the Dropout layer after each Linear layer. |
None
|
zero_centered
|
bool
|
bool Whether the output of this module is centered at 0. If the specified activation function changes the centroid of the output distribution, e.g. ReLU and LeakyReLU, the activation function won't be attached to the final Linear layer if zer_centered is set to True. |
False
|
Source code in speechain/module/prenet/conv1d.py
150 151 152 153 154 155 156 157 158 159 160 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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|