First working version of stacked autoencoder