## Details of the Hierarchical VAE (Part 2)

So, as a recap, here’s a (badly drawn) diagram of the architecture:

Hopefully, it makes sense. The goal is to reiterate the fact that the feature extraction from the image is performed by the same function with shared parameters. Also, the latent variables are fed back into the convolution upsampling process after they are sampled when sampling from the conditional prior.

For the sake of simplicity in the model descriptions, there are a couple of minor details I’ve left out. For example, I’ve made connections from the feature maps of the encoder to the decoder with the same feature map size in order to “re-include” information from the immediate border. This helps with giving more consistent colours with border at the edges of the inpainted region.

## Instability in the KL terms

One problem that occurs during training VAE models with conditional priors is that the models learnt for $p(\z_l|\z_{l+1})$ and $q(\z_l|\z_{l-1})$ don’t match up. This causes a big penalty, which affects the gradients being backpropagated. Because of the bigger number of random variables, this problem is compounded when training this model. Batch norm worked exceedingly well at remedying these problems.

However, the model then starts to overfit very easily. Despite this, the samples from an overfitted model do not display any semblance of memorising pictures from the training data. The following are plots of the training curves and validation curves.

The difference between the KL-divergence terms in the lower layers between training and validation grows as training continues. This means that the generative portion of the model cannot successfully match the distribution of the lower layers’ latent variables given the latent variables in the higher layers.

## Remedies and Future Work?

One possible solution to this would be to go the way of the PixelVAE, and introduce an autoregressive structure at every layer. I did briefly consider implementing DeepMind’s multi-scale alternative to pixel-by-pixel “drawing”, but the time that that would involve was too much.

Also included in the project was caption data, which may provide more information about the region that requires inpainting. I didn’t use that data in my project, though I doubt it would help much.