Introduction to Normalizing Flows

One of the best known approaches to learn a generative model of data is certainly the adversarial one. It involves pitching two networks against each other so that they jointly improve until one of them (the generator) reproduces data that closely match the data from the training distribution. While generative adversarial networks have shown impressive results, they require optimizing a two-player minimax game which is not stable and not easily tunable (see this post for a PyTorch implementation).

Another well known approach is the variational one. …


If you are working in science, chances are that you have encountered a density that you can only evaluate to a constant factor. If you want to sample from such a distribution, well-studied methods exist such as Markov Chain Monte Carlo or rejection sampling. You may also use importance sampling to get properties about the target distribution such as its expectation.

In this post we will use normalizing flows (that I described in a previous post) to fit the target density. …


In my previous post, I implemented the paper Auto-Encoding Variational Bayes in order to generate pictures of human faces. In this post, we will keep exploring generative models and will focus on generative adversarial networks.

We will implement the famous Generative Adversarial Networks paper in about 100 lines of code.

My aim is to reproduce results from the paper as closely as possible and therefore, this time we will not generate pictures of human faces but we will train our model on the MNIST dataset in order to generate handwritten digits.

The main idea behind generative adversarial networks is to…


If you have ever needed a picture of a fake person, you might know the following website:

Now, imagine that you were asked to design their algorithm — generate random pictures of fake persons. To draw a face, you will need to define what is a face in the first place as well as its characteristics and attributes. Then, for each attribute, you will have to define their possible colors, shapes, proportions, ... Finally and probably the more difficult challenge, you will need to assemble all of them in a coherent way. Are you ready for the challenge?

Well, putting…

Papers in 100 Lines of Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store