WaveNet factorizes the joint probability of a waveform x={x1,…,xT} into a product of conditional probabilities of each sample.
p(x)=t=1∏Tp(xt∣x1,…,xt−1)
These conditional probabilities are modeled by a network of stacked convolutional layers. There is no pooling, and the output has the same length as the input. The left side of the figure at the top of the article shows the overall flow, and the right side shows the stack of dilated causal convolutions.
- Quantization: handling 16-bit values directly would require probabilities over 65,536 classes per sample. Instead, a μ-law transformation is applied to samples normalized to −1<xt<1, which are then quantized to 256 levels (μ=255).
- Causal convolution: the first layer is a convolution whose output at time t depends only on x1,…,xt. For 1D data, it can be made simply by shifting the output of an ordinary convolution by a few samples.
- Stack residual blocks: each block consists of a dilated convolution, a gated activation, and a 1×1 convolution. The dilation doubles at each layer and repeats once it reaches its limit (1, 2, 4, …, 512, 1, 2, 4, …, 512, …).
- Residual and skip connections: the output of the 1×1 convolution is added to the block's input and passed to the next block (residual connection), and is also sent to the output side as a skip connection.
- Output layers: the skip connections of all blocks are summed and passed through ReLU → 1×1 convolution → ReLU → 1×1 convolution → softmax to produce a 256-class distribution over the next sample.
- Generation: during training the whole ground-truth waveform is known, so predictions for all time steps can be computed in parallel. During generation, one sample is drawn from the distribution and fed back as input to predict the next sample, and this is repeated.
The μ-law transformation is given by the following equation.
f(xt)=sign(xt)ln(1+μ)ln(1+μ∣xt∣)
Because it divides small amplitudes finely and large amplitudes coarsely, the same 256 levels reconstruct the original sound more faithfully than uniform quantization. The paper notes that, especially for speech, the quantized-and-reconstructed signal sounded very similar to the original.
The gated activation has the same form as in gated PixelCNN. With Wf,k and Wg,k as the filter and gate convolution weights of layer k, it is computed as follows (∗ is convolution, ⊙ is element-wise product, and σ is the sigmoid).
z=tanh(Wf,k∗x)⊙σ(Wg,k∗x)
The tanh side decides "what to pass" and the σ side decides "how much to pass". The paper reports that in initial experiments this form worked significantly better than ReLU for modeling audio.
The conditional WaveNet models p(x∣h)=∏tp(xt∣x1,…,xt−1,h) conditioned on an additional input h. There are two ways to inject the condition.
- Global conditioning: a single vector h shared across all time steps, such as a speaker embedding, is turned into a linear projection V⋅,k⊤h and added inside the tanh and σ.
- Local conditioning: a time series h with a coarser time resolution than the audio, such as linguistic features, is upsampled with a transposed convolution to y at the audio's resolution, turned into a 1×1 convolution V⋅,k∗y, and added.
With local conditioning, the gate becomes the following.
z=tanh(Wf,k∗x+Vf,k∗y)⊙σ(Wg,k∗x+Vg,k∗y)
The paper also tried repeating the values of h along time instead of using a transposed convolution, and found it slightly worse.
The large speed difference between training and generation is a property shared by all autoregressive models. In training, the "true past" can be used as input, so convolutions compute all time steps at once. In generation, the "model's own past" is needed, so the whole network has to run each time one sample is produced.