Rewrite of AutoEncoder class