added validation to mnist example