works on smaller version of mnist test, but still much slower.