Refactored autoencoder.