Deep Autoencoder Demo - Denoising and Compression
To encode and decode using the 30-dimensional autoencoder, press the "Redraw" button. Reconstructions will be much better if images are centered and appropriately sized (use the reconstructions as an example).
Welcome to the third part on autoencoders. To understand what is happening here, you should read part 1 and part 2.
This demo shows how autoencoders can be used for data compression and denoising. To see how it works, draw an image in one of the boxes on the left. There are two options: an autoencoder which compresses the image to 2 numbers (this is the one we've been using in the previous demos) and a different autoencoder which compresses the images to 30 numbers. The autoencoder will encode your drawing to 2 or 30 numbers, which you see as the colored dots in the middle. Then, the decoder will decode those numbers into an image. If the encoder and decoder do their jobs well, the reconstruction should look similar to the image you drew.
This demonstrates that autoencoders can be used for compression by reducing each image from 784 numbers to just 2 or 30. This would help significantly if you wanted to transfer an image over the internet, since you could compress it using the encoder, send the compressed version over the internet, and then the recipient could decompress it using the decoder (assuming, of course, that it's an image of a number). In the case of the 2D autoencoder, this would reduce the file size by more than 300 times. However, as you can see if you try to use the 2D autoencoder above, the reconstructions are very inaccurate. If you use the 30D autoencoder instead, you can reduce the file size by over 25 times while still getting very accurate reconstructions.
Another important note here is that the autoencoders work best when the images they are given are centered and appropriately sized. For the 2D autoencoder, it will likely mess up its reconstructions if the image is even slightly off-center or the wrong size. That can be fixed automatically, but it still points out another important aspect of all machine learning models: the data they're given is the biggest factor in their quality. These autoencoders were given data from a database of 60,000 handwritten digits, all of which were automatically centered and resized to make the data more consistent. They never saw any numbers which were unusually small, large, or off-center, so they never learned to work with them. This can be solved by adding shifted and resized versions of the original images into the training set, or by pre-processing every image before it is fed into the autoencoder. Either way, this shows how important it is to understand the problems, biases, and holes in the data you feed to a machine learning algorithm.
Finally, these autoencoders can be used to remove noise from an image. To try this out, draw an image in one of the boxes and look at its reconstruction. Then, press the "Add noise" button and reconstruct that image. It is likely that the reconstruction barely changed. In the case of the 30D autoencoder, this often works after pressing "Add noise" four or five times. This works because each dot in the encoded representation (which represents one of the encoded numbers) has learned some sets of patterns which activate it. When one of those dots is green, it is because some pattern in the image matched a pattern which activates that dot. The way these patterns are detected is similar to a weighted average of the pixels, although it is a little more complicated in reality. Since it is like a weighted average, adding noise does not actually do much to change the activation of an individual dot. This is because adding noise essentially makes each pixel a little lighter or a little darker, but since each dot takes multiple pixels into consideration, the average of all those changes is close to zero. The noise is mostly considered on a high level where it essentially cancels itself out. Since each dot hardly changes, the overall reconstruction stays nearly the same. Of course, if you add a lot of noise, the noise is a lot less likely to "cancel itself out" and the reconstruction will be different.
These two applications are some of the most easy to understand and demonstrate, but autoencoders have a plethora of other applications. The wikipedia article on autoencoders gives a more comprehensive list and describes the many variations of autoencoders which exist.
That concludes the series on autoencoders. Hopefully, you now know a little bit more about how an autoencoder and its two halves work.