Count the code before calling it a bottleneck
shape▲▲△Exact integers.
STATEMENT
Track shapes and parameters through a dense and a convolutional autoencoder for the same image, and find the two places where the convolutional one goes wrong.
GIVEN
One input is a image, numbers.
The dense autoencoder has layer widths , , , , , with a bias on every layer.
The convolutional encoder is two layers with kernels, stride and padding , taking channel to and then to . The decoder is two transposed convolutions with the same kernel, stride and padding, taking channels to and then to . All four layers have biases.
FIND
(a) The dense parameter count, untied and with tied weights. (b) The spatial sizes through the convolutional encoder, and how many numbers its code holds. (c) The decoder’s output size with output padding and with . (d) The convolutional parameter count. (e) The code channel counts for which the convolutional code is narrower than its input.
STRATEGY
Count each dense layer as inputs times outputs plus outputs. Use (I.11.4) for the encoder’s sizes and (I.11.5) for the decoder’s.
SOLUTION
(a) The four dense layers hold
for a total of . With tied weights the two decoder matrices are transposes of the encoder’s. The weights are then and the four bias vectors add , for . The code is numbers, times fewer than the input.
(b) By (I.11.4), with no dilation,
The code has shape and holds numbers, exactly as many as the input. This is the first fault. Each layer halved the height and the width and the picture looks like an hourglass, but the channel count grew as fast as the grid shrank. By count, nothing forces this code to discard anything.
(c) By (I.11.5) a transposed layer returns for output padding . With the sizes run . The reconstruction is , with numbers, and cannot be compared with a target. This is the second fault. With they run .
The ambiguity is real. Under the encoder’s stride-two layer an input of size and one of size both give . The transposed layer cannot know which it is undoing, and output padding tells it.
(d) A transposed convolution stores its weight with shape and one bias per output channel. The four layers hold
a total of , against for the dense stack.
(e) A code of channels on the grid holds numbers. It is narrower than the input when , that is, . With the code holds numbers, a quarter of the input.
Answer
(a) untied and tied. (b) ; the code holds numbers. (c) without output padding and with it. (d) . (e) Fewer than code channels.
Check — sanity
The tied count is half the untied weights plus all the biases: . The transposed sizes and are the encoder’s sizes read backwards.
Where this breaks
A count of numbers is a necessary check and not a sufficient one. A code with fewer numbers than the input can still memorise (I.12.B04), and shared, local weights restrict a convolutional autoencoder in ways the count does not show. The count catches only the case where no restriction was imposed at all.
Variation
With kernels, stride and padding , the encoder still gives , and the transposed layer returns with no output padding. An even input size is then recovered without the extra argument.