mini batch training and infinite loops