Constrained neural network for unconstrained handwritten digit recognition