First implementation of autoencoder, not vectorized