transform the dataset in the same form as mnist.pkl.gz