Added early stopping to the solver

I added early stopping to the solver. You can now choose whether caffe should stop after a maximum number of iterations or alternatively if the test accuracy doesn't improve for a given number of tries.