Learning Convex Inference of Marginals