batch version of autoencoders