sgd for mnist, write stats every epoch