SGB: Stochastic Gradient Bound Method for Optimizing Partition Functions