# geometric_losses_for_distributional_learning__29ca5c78.pdf Geometric Losses for Distributional Learning Arthur Mensch 1 2 Mathieu Blondel 3 Gabriel Peyr e 1 2 Building upon recent advances in entropyregularized optimal transport, and upon Fenchel duality between measures and continuous functions, we propose a generalization of the logistic loss that incorporates a metric or cost between classes. Unlike previous attempts to use optimal transport distances for learning, our loss results in unconstrained convex objective functions, supports infinite (or very large) class spaces, and naturally defines a geometric generalization of the softmax operator. The geometric properties of this loss make it suitable for predicting sparse and singular distributions, for instance supported on curves or hyper-surfaces. We study the theoretical properties of our loss and showcase its effectiveness on two applications: ordinal regression and drawing generation. 1. Introduction For probabilistic classification, the most popular loss is arguably the (multinomial) logistic loss. It is smooth, enabling fast convergence rates, and the softmax operator provides a consistent mapping to probability distributions. In many applications, different costs are associated to misclassification errors between classes. While a cost-aware generalization of the logistic loss exists (Gimpel & Smith, 2010), it does not provide a cost-aware counterpart of the softmax. The softmax is pointwise by nature: it is oblivious to misclassification costs or to the geometry of classes. Optimal transport (Wasserstein) losses have recently gained popularity in machine learning, for their ability to compare probability distributions in a geometrically faithful manner, with applications such as classification (Kusner et al., 2015), clustering (Cuturi & Doucet, 2014), domain 1 Ecole Normale Sup erieure, DMA, Paris, France 2CNRS, France 3NTT Communication Science Laboratories, Kyoto, Japan. Correspondence to: AM , MB , GP . Proceedings of the 36 th International Conference on Machine Learning, Long Beach, California, PMLR 97, 2019. Copyright 2019 by the author(s). adaptation (Courty et al., 2017), dictionary learning (Rolet et al., 2016) and generative models training (Montavon et al., 2016; Arjovsky et al., 2017). For probabilistic classification, Frogner et al. (2015) proposes to use entropyregularized optimal transport (Cuturi, 2013) in the multilabel setting. Although this approach successfully leverages a cost between classes, it results in a non-convex loss, when combined with a softmax. A similar regularized Wasserstein loss is used by Luise et al. (2018) in conjunction with a kernel ridge regression procedure (Ciliberto et al., 2016) in order to obtain a consistency result. The relation between the logistic loss and the maximum entropy principle is well-known. Building upon a generalization of the Shannon entropy originating from entropy regularized optimal transport (Feydy et al., 2019) and Fenchel duality between measures and continuous functions, we propose a generalization of the logistic loss that takes into account a metric or cost between classes. Unlike previous attempts to use optimal transport distances for learning, our loss is convex, and naturally defines a geometric generalization of the softmax operator. Besides providing novel insights in the logistic loss, our loss is theoretically sound, even when learning and predicting continuous probability distributions over a potentially infinite number of classes. To sum up, our contributions are as follows. Organization and contributions. We introduce the distribution learning setting, review existings losses leveraging a cost between classes and point out their shortcomings ( 2). Building upon entropy-regularized optimal transport, we present a novel cost-sensitive distributional learning loss and its corresponding softmax operator. Our proposal is theoretically sound even in continuous measure spaces ( 3). We study the theoretical properties of our loss, such as its Fisher consistency ( 4). We derive tractable methods to compute and minimize it in the discrete distribution setting. We propose an abstract Frank-Wolfe scheme for computations in the continuous setting. Finally, we demonstrate its effectiveness on two discrete prediction tasks involving a geometric cost: ordinal regression and drawing generation using VAEs ( 5). Geometric Losses for Distributional Learning Notation. We denote X a finite or infinite input space, and Y a compact potentially infinite output space. When Y is a finite set of d classes, we write Y = [d] {1, . . . , d}. We denote C(Y), M(Y), M+(Y) and M+ 1 (Y) the sets of continuous (bounded) functions, Radon (positive) measures and probability measures on Y. Note that in finite dimensions, M+ 1 ([d]) = d is the probability simplex and C([d]) = Rd. We write vectors in Rd and continuous functions in C(Y) with small normal letters, e.g., f, g. In the finite setting, where Y = {y1, . . . , yd}, we define fi f(yi). We write elements of d and measures in M(Y) with greek letters α, β. We write matrices and operators with capital letters, e.g., C. We denote by and the tensor product and sum, and , the scalar product. 2. Background In this section, after introducing distributional learning in a discrete setting, we review two lines of work for taking into account a cost C between classes: cost-augmented losses, and geometric losses based on Wasserstein and energy distances. Their shortcomings motivate the introduction of a new geometric loss in 3. 2.1. Discrete distribution prediction and learning We consider a general predictive setting in which an input vector x X is fed to a parametrized model gθ : X Rd (e.g., a neural network), that predicts a score vector f = gθ(x) Rd. At test time, that vector is used to predict the most likely class ˆy = argmaxy [d] fy. In order to predict a probability distribution α d, it is common to compose gθ with a link function ψ(f), where ψ: Rd d. A typical example of link function is the softmax. To learn the model parameters θ, it is necessary to define a loss ℓ(α, f) between a ground-truth α d and the score vector f Rd. Composite losses (Reid & Williamson, 2010; Williamson et al., 2016) decompose that loss into a loss ℓ (α, β), where ℓ : d d R and ψ: ℓ(α, f) ℓ (α, ψ(f)). Note that depending on ℓ and ψ, ℓis not necessarily convex in f. More recently, Blondel et al. (2018; 2019) introduced Fenchel-Young losses, a generic way to directly construct a loss ℓand a corresponding link ψ. We will revisit and generalize that framework to the continuous output setting in the sequel of this paper. Given a loss ℓand a training set of input-distribution pairs, (xi, αi), where xi X and αi d, we then minimize P i ℓ(αi, gθ(xi)), potentially with regularization on θ. 2.2. Cost-augmented losses Before introducing a new geometric cost-sensitive loss in 3, let us now review classical existing cost-sensitive loss functions. Let C be a d d matrix, such that cy,y 0 is the cost of misclassifying class y [d] as class y [d]. We assume cy,y = 0 for all y [d]. To take into account the cost C, in the single label setting, it is natural to define a loss L: [d] Rd R as follows L(y, f) = cy,y where y argmax i [d] fi. (1) To obtain a loss ℓ: d Rd R, we simply define ℓ(δy, f) L(y, f), where δy is the one-hot representation of y [d]. Note that choosing cy,y = 1 when y = y and cy,y = 0 otherwise (i.e., C = 1 Id d) reduces to the zero-one loss. To obtain a convex upper-bound, (1) is typically replaced with a cost-augmented hinge loss (Crammer & Singer, 2001; Tsochantaridis et al., 2005): L(y, f) = max i [d] cy,i + fi fy. Replacing the max above with a log-sum-exp leads to a cost-augmented version of the logistic (or conditional random field) loss (Gimpel & Smith, 2010). Another convex relaxation is the cost-sensitive pairwise hinge loss (Weston & Watkins, 1999; Duchi et al., 2018). Remarkably, all these losses use only one row of C, the one corresponding to the ground truth y. Because of this dependency on y, it is not clear how to define a probabilistic mapping at test time. In this paper, we propose a loss which comes with a geometric generalization of the softmax operator. That operator uses the entire cost matrix C. 2.3. Wasserstein and energy distance losses Wasserstein or optimal transport distances recently gained popularity as a loss in machine learning for their ability to compare probability distributions in a geometrically faithful manner. As a representative application, Frogner et al. (2015) proposed to use entropy-regularized optimal transport (Cuturi, 2013) for cost-sensitive multi-label classification. Effectively, optimal transport lifts a distance or cost C : Y Y R+ to a distance between probability distributions over Y. Following Genevay et al. (2016), given a ground-truth probability distribution α d and a predicted probability distribution β d, we define OTC,ǫ(α, β) min π U(α,β) π, C + εKL(π|α β), (2) where U is the transportation polytope, a subset of d d whose elements π have constrained marginals: π1 = α and π 1 = β. KL is the Kullback Leibler divergence (a.k.a. relative entropy). Because β needs to be a valid probability distribution, Frogner et al. (2015) propose to use β = ψ(f) = softmax(f), where f Rd is a vector of prediction scores. Unfortunately, the resulting composite loss, ℓ(α, f) = OTC,ǫ(α, softmax(f)), is not convex w.r.t. f. Another class of divergences between measures α and β Geometric Losses for Distributional Learning stems from energy distances (Sz ekely & Rizzo, 2013) and maximum mean discrepancies. However, composing these divergences with a softmax again breaks convexity in f. In contrast, our proposal is convex in f and defines a natural geometric softmax. 3. Continuous and cost-sensitive distributional learning and prediction In this section, we construct a loss between probability measures and score functions, canonically associated with a link function. Our construction takes into account a cost function C : Y Y R between classes. Unlike existing methods reviewed in 2.2, our loss is well defined and convex on compact, possibly infinite spaces Y. We start by extending the setting of 2.1 to predicting arbitrary probabilities, for instance having continuous densities with respect to the Lebesgue measure or singular distributions supported on curves or surfaces. 3.1. Continuous probabilities and score functions We consider a compact metric space of outputs Y, endowed with a symmetric cost function C : Y Y R. We wish to predict probabilities over Y, that is, learn to predict distributions α M+ 1 (Y). The space of probability measures forms a closed subset of the space of Radon measures M(Y), i.e., M+ 1 (Y) M(Y). From the Riesz representation theorem, M(Y) is the topological dual of the space of continuous measures C(Y), endowed with the uniform convergence norm . The topological duality between the primal M(Y) and the dual C(Y) defines a pairing, similar to a scalar product , between these spaces: Y f(y)dα(y) = E[f(Y )], for all α M(Y) and f C(Y), where Y is a random variable with law α. This pairing also defines the natural topology to compare measures and to differentiate functionals depending on measures. This is the so-called weak topology, which corresponds to the convergence in law of random variables. A sequence αn is said to converge weak to some α if for all functions f C(Y), αn, f α, f . Note that when endowing M(Y) with this weak topology, the dual of M(Y) is C(Y), which is the key to be able to use duality (and in particular Legendre-Fenchel transform) from convex optimization. Using this topology is fundamental to define geometric losses that can cope with arbitrary, possibly highly localized or even singular distributions (for instance sparse sums of Diracs or measures concentrated on thin sets such as 2-D curves or 3-D surfaces). Similarly to the discrete setting reviewed in 2.1, in the continuous setting, we now wish to predict a distribution α M+ 1 (Y) by setting α = ψ(f), where f = gθ(x) C(Y), gθ : X C(Y) (i.e., gθ is unconstrained), and ψ: C(Y) M+ 1 (Y) is a link function. We propose to use maps between the primal M+ 1 (Y) and the dual score space C(Y) as link functions. As we shall see, such mirror maps are naturally defined by continuous convex function on the primal space, through Fenchel-Legendre duality. Our framework recovers the discrete case Y = [d] as a particular case, with d corresponding to M+ 1 ([d]) and Rd to C([d]), though the isomorphisms α Pd i=1 αiδi and for all i [d], f(i) = fi. Regularization of optimal transport is our key tool to construct entropy functions which are continuous with respect to the weak topology, and that can be conjugated to define a C(Y) M+ 1 (Y) link function. It allows us to naturally leverage a cost C : Y Y R between classes. 3.2. An entropy function for continuous probabilities The regularized optimal transport cost (2) remains well defined when α and β belong to a continuous measure space M+ 1 (Y), with U now being a subset of M+ 1 (Y Y) with marginal constraints. It induces the self-transport functional (Feydy et al., 2019), that we reuse for our purpose: 2OTC,ε=2(α, α) for α M+ 1 (Y) + otherwise. (3) We will omit the dependency of Ωon C when clear from context. It is shown by Feydy et al. (2019) that Ωis continuous and convex on M(Y), and strictly convex on M+ 1 (Y), where continuity is taken w.r.t. the weak topology. We call Ω, the Sinkhorn negentropy. As a negative entropy function, it can be used to measure the uncertainty in a probability distribution (lower is more uncertain), as illustrated in Figure 2. It will prove crucial in our loss construction. In the above, we have set w.l.o.g. ε = 2 to recover simple asymptotical behavior of Ω, as will be clear in Prop. 1. We first recall some known results from Feydy et al. (2019). Using Fenchel-Rockafellar duality theorem (Rockafellar, 1966), the function Ωrewrites as the solution to a Kantorovich-type dual problem (see e.g., Villani, 2008). For all α M+ 1 (Y), we have that ΩC(α) = max f C(Y) α, f log α α, e f f C where we use the homogeneous dual (i.e. with a log in the maximization), as explained in Cuturi & Peyr e (2018). Gradient and extrapolation. Ωis differentiable in the sense of measures (Santambrogio, 2015), meaning that there exists a continuous function Ω(α) such that, for all Geometric Losses for Distributional Learning ξ1, ξ2 M+ 1 (Y), t > 0, Ω(α+t(ξ2 ξ1)) = Ω(α)+t ξ2 ξ1, Ω(α) +o(t). (5) As shown in Feydy et al. (2019), this function f = Ω(α), that we call the symmetric Sinkhorn potential, is a particular solution of the dual problem. It is the only function in C(Y) such that f = T( f, α), where the soft Ctransform operator (Cuturi & Peyr e, 2018) is defined as T(f, α)(y) 2 log α, e This operator can be understood as the log-convolution of the measure αe f 2 with the Sinkhorn kernel e C 2 . The Sinkhorn potential f has the remarkable property of being defined on all Y, even though the support of α may be smaller. Given any dual solution g to (4), which is defined α-almost everywhere, we have f = T( g, α), i.e. f extrapolates the values of g on the support of α, using the Sinkhorn kernel. Special cases. The following proposition, which is an original contribution, shows that the Sinkhorn negentropy asymptotically recovers the negative Shannon entropy and Gini index (Gini, 1912) when rescaling the cost. The Sinkhorn negentropy therefore defines a parametric family of negentropies, recovering these important special cases. Note however that on continuous spaces Y, the Shannon entropy is not weak continuous and thus cannot be used to define geometric loss and link functions, the softmax link function being geometry-oblivious. Similarly, the Gini index is not defined on M+ 1 (Y), as it involves the squared values of α in a discrete setting. Proposition 1 (Asymptotics of Sinkhorn negentropies). For Y compact, the rescaled Sinkhorn negentropy converges to a kernel norm for high regularization ε. Namely, for all α M+ 1 (Y), we have εΩC/ε(α) ε + 1 2 α α, C . Let Y = [d] be discrete and choose C = 1 Id d. The Sinkhorn negentropy converges to the Shannon negentropy for low-regularization, and into the negative Gini index for high regularization: ΩC/ε(α) ε 0 α, log α , εΩC/ε(α) ε + 1 2( α 2 2 1). Proof is provided in A.1. The first part of the proposition shows that the Sinkhorn negentropies converge to a kernel norm (see e.g., Sriperumbudur et al., 2011). This is similar to the regularized Sinkhorn divergences converging to an Energy Distance (Sz ekely & Rizzo, 2013) for ε (Genevay et al., 2018; Feydy et al., 2019). Figure 1. The symmetric Sinkhorn potentials form a distance field to a weighted measure. The link function ψ = Ω (f) allows to go back from this field in C(Y) to a measure α M+ 1 (Y). From probabilities to potentials. The symmetric Sinkhorn potential f = Ω(α) is a continuous function, or a vector in the discrete setting. It can be interpreted as a distance field to the distribution α. We visualize this field on a 2D space in Figure 1, where Y is the set of h w pixels of an image, and we wish to predict a 2-dimensional probability distribution in M+ 1 (Y) = h w. Predicting a distance field f C(Y) to a measure is more convenient than predicting a distribution directly, as it has unconstrained values and is therefore easier to optimize against. For this reason, we propose to learn parametric models that predict a distance field f = gθ(x) given an input x X. In the following section, we construct a link function ψ : C(Y) M+ 1 (Y), for general probability measure and function spaces M+ 1 (Y) and C(Y), so to obtain a distributional estimator αθ = ψ gθ : X M+ 1 (Y). 3.3. Fenchel-Young losses in continuous setting To that end, we generalize in this section the recentlyproposed Fenchel-Young (FY) loss framework (Blondel et al., 2018; 2019), originally limited to discrete costoblivious measure spaces, to infinite measure spaces. Inspired by that line of work, we use Legendre-Fenchel duality to define loss and link functions from Sinkhorn negative entropies, in a principled manner. We define the Legendre Fenchel conjugate Ω : C(Y) R of Ωas Ω (f) max α M+ 1 (Y) α, f Ω(α). Rigorously, Ω (f) is a pre-conjugate, as Ωis defined on M(Y), the topological dual of continuous functions C(Y). For a comprehensive and rigorous treatment of the theory of conjugation in infinite spaces, and in particular Banach spaces as is the case of C(Y), see Mitter (2008). As Ωis strictly convex, Ω is differentiable everywhere and we have, from a Danskin theorem (Danskin, 1966) with left Banach space and right compact space (Bernhard & Rapaport, 1995, Theorem C.1): Ω (f) argmax α M+ 1 (Y) α, f Ω(α) C(Y). That gradient can be used as a link ψ from f C(Y) to α M+ 1 (Y). It can also be interpreted as a regularized Geometric Losses for Distributional Learning prediction function (Blondel et al., 2018; Mensch & Blondel, 2018). Following the FY loss framework, we define the loss associated with Ω by ℓΩ(α, f) Ω (f) + Ω(α) α, f . (6) In the discrete single-label setting, that loss is also related to the construction of Duchi et al. (2018, Proposition 3). From the Fenchel-Young theorem (Rockafellar, 1970), ℓΩ(α, f) 0, with equality if and only if α = Ω (f). The loss ℓΩis thus positive, convex and differentiable in its second argument, and minimizing it amounts to find the pre-image f of the target distribution α with respect to the link (mapping) Ω . Our construction is a generalization of the Fenchel-Young loss framework (Blondel et al., 2018; 2019), in the sense that it relies on topological duality between C(Y) and M+ 1 (Y), instead of the Hilbertian structure of Rd and d, to construct the loss ℓΩand link function Ω . We now instantiate the Fenchel-Young loss (6) with Sinkhorn negentropies in order to obtain a novel cost-sensitive loss. 3.4. A new geometrical loss and softmax The key ingredients to derive a Fenchel-Young loss ℓΩand a link Ω are the conjugate Ω and its gradient. Remarkably, they enjoy a simple form with Sinkhorn negentropies, as shown in the following proposition. Proposition 2 (Conjugate of the Sinkhorn negentropy). For all f C(Y), the Legendre-Fenchel conjugate Ω of Ωdefined in (3) and its gradient read g-LSE(f) Ω (f) = log min α M+ 1 (Y) Φ(α, f) g-softmax(f) Ω (f) = argmin α M+ 1 (Y) Φ(α, f) where Φ(α, f) α α, exp( f f + C and where g stands for geometric and LSE for log-sum-exp. The proof can be found in A.2. Ω (f) is the usual Fr echet derivative of Ω , that lies a priori in the topological dual space of C(Y), i.e. M(Y). From a Danskin theorem (Bernhard & Rapaport, 1995), it is in fact a probability measure. The probability distribution α = Ω (f) is typically sparse, as the minimizer of a quadratic on a convex subspace of M(Y). We call the loss ℓΩgenerated by the Sinkhorn negentropy g-logistic loss. Special cases. Let Y = [d] and C = 1 Id d (0-1 cost matrix). From Prop. 1, Ωasymptotically recovers the negative Shannon entropy when Ω= ΩC ε as ε 0 and the negative Gini index when Ω= εΩC ε , as ε . Ω is then equal to softmax(f) exp f P i exp fi , and to sparsemax(f) argminα d α f 2 (Martins & Astudillo, 2016), respectively. Likewise, ℓΩrecovers the logistic and sparsemax losses. When ε 0, because ( C ε )y,y = if y = y and 0 otherwise, we see that the logistic loss infinitely penalizes inter-class errors. That is, to obtain zero logistic loss, the model must assign probability 1 to the correct class. The limit case ε 0 is the only case for which gsoftmax always outputs completely dense distributions. In the continuous case, εΩ C/ε(f/ε) degenerates into a positive deconvolution objective with simplex constraint: max α M+ 1 (Y) α, f 1 Fig. 1 shows that Ω has indeed a deconvolutional effect. 3.5. Computation Before studying the g-logistic loss ℓΩand link function Ω (f), we now describe practical algorithms for computing Ω (f) and Ω (f) in the discrete and continuous cases. The key element in using the g-LSE as a layer in an arbitrary complex model is to minimize the quadratic function Φf Φ( , f), on M+ 1 (Y). We can then use the minimum value in the forward pass, and the minimizer in the backward pass, during e.g. SGD training. Continuous optimisation. In the general case where Y is compact, we cannot represent α M+ 1 (Y) using a finite vector. Yet, we can use a Frank-Wolfe scheme to progressively add spikes, i.e. Diracs to an iterate sequence αt. For this, we need to compute, at each iteration, the gradient of Φf in the sense of measure (5), i.e. the function in C(Y) Φf(α) = exp( f + T( f, α) that simply requires to compute the C-transform of f on the measure α, similarly to regularized optimal transport. The simplest Frank-Wolfe scheme then updates yt argmin Y Φf(αt 1), αt = αt 1+ 2 t + 2(δyt αt 1). Indeed, for h C(Y), the minimizer of h, on M+ 1 (Y) is the Dirac δy where y Y minimizes h. This optimization scheme may be refined to ensure a geometric convergence of Φf(αt). It can be used to identify Diracs from a continuous distance field f, similar to super-resolution approaches proposed in Bredies & Pikkarainen (2013); Boyd et al. (2017). It requires to work with computer-friendly representation of f, so that we can obtain an approximation of yt efficiently, using e.g. non-convex optimization. Another approach is to rely on a deep parametrization of a particle swarm, as proposed by Boyd et al. (2018). We leave such an application for future work, and focus on an efficient discrete solver for the g-LSE and g-softmax. Geometric Losses for Distributional Learning 2 0 2 f1 f2 C = 0 γ γ 0 0.0 0.5 1.0 α Ω([α, 1 α]) γ = γ = 0.1 γ = 2 0.0 0.5 1.0 1.5 2.0 ef1 0.0 0.5 1.0 1.5 2.0 ef1 Figure 2. Left: Geometric softmax and Sinkhorn entropy, for symmetric cost matrices, in the binary case. Predictions from the g-softmax are sparse, as the minimizer of a convex quadratic on the simplex. Right: Level sets of the geometric conjugate. Introducing a cost matrix induces a deformation 2, the level-set of the log-sum-exp operator, onto the set of symmetric Sinkhorn potentials F. The geometric conjugate defines an extrapolation operator f f E that replaces the score function onto the cylinder F + R1. Discrete optimisation. In the discrete case, we can parametrize log Φ(f, ) in logarithmic space, by setting α = exp(l) LSE(l), with l Rd. Ω (f) then reads max l Rd log i,j=1 eli+lj fi+fj +ci,j 2 + 2LSE(l). (7) This objective is non-convex on Rd but invariant with translation and convex on {h Rd, LSE(l) = 0}. It thus admits a unique solution, that we can find using an unconstrained quasi-Newton solver like L-BFGS (Liu & Nocedal, 1989), that we stop when the iterates are sufficiently stable. For l that maximizes (7), the gradient Ω (f) = softmax(l) is used for backpropagation and at test time. As Ω (f) is sparse, we expect some coordinates li to go to . In practice, αi then underflows to 0 after a few iterations. Two-dimensional convolution. In the discrete case, when dealing with two-dimensional potentials and measures, the objective function (7) can be written with a convolution operator, as log el f 2 where C R(h w)2. It is therefore efficiently computable and differentiable on GPUs, especially when the kernel C is separable in height and width, e.g. for the ℓ2 2 norm, in which case we perform 2 successive one-dimensional convolutions. We use this computational trick in our variational auto-encoder experiments ( 5). 4. Geometric and statistical properties We start by studying the mirror map Ω , that we expect to invert the mapping α Ω(α). This study is necessary as we cannot rely on typical conjugate inversion results (e.g., Rockafellar, 1970, Theorem 26.5), that would stipulate that Ω = ( Ω) 1 on the domain of Ω . Indeed, this result is stated in finite dimension, and requires that Ωand Ω be Legendre, i.e. be strictly convex and differentiable on their domain of definition, and have diverging derivative on the boundaries of these domains (see also Wainwright & Jordan, 2008). This is not the case of the Sinkhorn ne- gentropy, which requires novel adjustements. With these at hands, we show that parametric models involving a final g-softmax layer can be trained to minimize a certain wellbehaved Bregman divergence on the space of probability measures. Proofs are reported in A.3 and A.4 4.1. Geometry of the link function We have constructed the link function Ω in hope that it would allow to go from a symmetric Sinkhorn potential f = Ω(α) back to the original measure α. The following lemma states that this is indeed the case, and derives two consequences on the space of symmetric Sinkhorn potentials, defined as F {f C(Y), f = Ω(α)}. Lemma 1 (Inversion of the Sinkhorn potentials). α M+ 1 (Y), Ω Ω(α) = α. f F, Ω Ω (f) = f, Ω (f) = 0. The computation of the Sinkhorn potential thus inverts the g-LSE operator on the space F, which is included in the 0-level set of Ω . This is similar to the set FShannon = {log α, α d} being the 0 level set of the log-sum-exp function when using the Shannon negentropy as Ω. This corollary is not sufficient for our purpose, as we want to characterize the action of Ω on all continuous functions f C(Y). For this, note that the g-LSE operator Ω has the same behavior as the log-sum-exp when composed with the addition of a constant c R: Ω (f + c) = Ω (f) + c, Ω (f + c) = Ω (f). (8) Therefore, for all f C(Y), Ω (f Ω (f)) = 0, which almost makes f Ω (f) a part of the space of potentials F. Yet, in contrast with the Shannon entropy case, the inclusion of (Ω ) 1(0) in F is strict. Indeed, following 3.2 f F implies that there exists α M+ 1 (Y) such that f = T( f, α) is the image of the C-transform operator. The operator Ω Ω has therefore an extrapolation effect, as it replaces f Ω (f) onto the set of Sinhorn potentials. This is made clear by the following proposition. Geometric Losses for Distributional Learning Proposition 3 (Extrapolation effect of Ω Ω ). For all f C(Y), we define the extrapolation of f to be f E T (f Ω (f)), Ω (f) + Ω (f). Then, for all f C(Y), Ω Ω (f) = f E Ω (f). The extrapolation operator translates f to (Ω ) 1(0), extrapolates f Ω (f) so that it becomes a Sinkhorn potential, then translates back the result so that Ω (f E) = Ω (f). Its effects clearly appears on Figure 2 (right), where we see that f E is a projection of f onto the cylinder F +R. 4.2. Relation to Hausdorff divergence Recall that the Bregman divergence (Bregman, 1967) generated by a strictly convex Ωis defined as DΩ(α, β) Ω(α) Ω(β) Ω(f), α β). When Ωis the classical negative Shannon entropy Ω(α) = α, log α , it is well-known that DΩequals the Kullback Leibler divergence and it is easy to check that ℓΩ(α, f) = DΩ(α, Ω (f)) = KL(α, softmax(f)). The equivalence between Fenchel-Young loss ℓΩ(α, f) and composite Bregman divergence DΩ(α, Ω (f)), however, no longer holds true when Ωis the Sinkhorn negentropy defined in (3). In that case, DΩcan be interpreted as an asymmetric Hausdorff divergence (Aspert et al., 2002; Feydy et al., 2019). It forms a geometric divergence akin to OT distances, and estimates the distance between distribution supports. As we now show, ℓΩprovides an upper-bound on the composition of that divergence with Ω . Proposition 4 (ℓΩupper-bounds Hausdorff divergence). DΩ(α, Ω (f)) = ℓΩ(α, f E) = ℓΩ(α, f) α, f E f ℓΩ(α, f) with equality if supp Ω (f) = supp α. In contrast with the KL divergence, the asymmetric Hausdorff divergence is finite even when supp α = supp β, a geometrical property that it shares with optimal transport divergences. We now use Prop. 4 to derive a new consistency result justifying our loss. Let us assume that input features and output distributions follow a distribution D M+ 1 (X M+ 1 (Y)). We define the Hausdorff divergence risk and the Fenchel-Young loss risk as E(β) E[DΩ(α, β(x))] and R(g) E[ℓΩ(α, g(x))], where the expectation is taken w.r.t. (x, α) D. We define their associated Bayes estimators as β argmin β : X M+ 1 (Y) E(β) and g argmin g : X C(Y) R(g). The next proposition guarantees calibration of ℓΩwith respect to the asymmetric Hausdorff divergence DΩ. Proposition 5 (Calibration of the g-logistic loss). The glogistic loss ℓΩwhere Ωis defined in (3) is Fisher consistent with the Hausdorff divergence DΩfor the same Ω. That is, E(β ) = R(g ), with g = Ω β . The excess of risk in the Hausdorff divergence is controlled by the excess of risk in the g-logistic loss. For all g : X C(Y), we have E( Ω g) E(β ) R(g) R(g ). This result, that follows the terminology of Tewari & Bartlett (2005), shows that ℓΩis suitable for learning predictors that minimize DΩ. 5. Applications We present two experiments that demonstrate the validity and usability of the geometric softmax in practical usecases. We provide a Py Torch package for reusing the discrete geometric softmax layer1. 5.1. Ordinal regression We first demonstrate the g-softmax for ordinal regression. In this setting, we wish to predict an ordered category among d categories, and we assume that the cost of predicting ˆy instead of y is symmetric and depends on the difference between ˆy and y. For instance, when predicting ratings, we may have three categories bad average good. This is typically modeled by a cost-function C(ˆy, y) = φ(|ˆy y|), where φ is the ℓ2 2 or ℓ1 cost. We use the real-world ordinal datasets provided by Gutierrez et al. (2016), using their predefined 30 cross-validation folds. Experiment and results. We study the performance of the geometric softmax in this discrete setting, where the score function is assumed to be a linear function of the input features x Rk, i.e, g W,b(x) = Wx + b, with b Rd, x Rk and W Rd k. We compare its performance to multinomial regression, and to immediate threshold and all-threshold logistic regression (Rennie & Srebro, 2005), using a reference implementation provided by Pedregosa et al. (2017). We use a cross-validated ℓ2 penalty term on the linear score model gθ. To compute the Hausdorff divergence at test time and the geometric loss during training, we set C(ˆy, y) = (ˆy y)2/2. The results, aggregated over datasets and cross-validation folds, are reported in Table 1. We observe that the g-logistic regression performs better than the others for the Hausdorff divergence on average. It performs slightly worse than a simple logistic regression in term of accuracy, but 1github.com/arthurmensch/g-softmax Geometric Losses for Distributional Learning Table 1. Performance of geometric loss as a drop-in replacement in linear models for ordinal regression. Our method performs better w.r.t. its natural metric, the Hausdorff divergence. LR LR(AT) LR(IT) g-logistic Haus. div. .46 .12 .47 .14 .59 .16 .44 .08 MAE .44 .09 .42 .06 .44 .08 .45 .09 Acc. .66 .07 .65 .06 .65 .06 .65 .07 slightly better in term of mean absolute error (MAE, the reference metric in ordinal regression). It thus provides a viable alternative to thresholding techniques, that performs worse in accuracy but better in MAE. It has the further advantage of naturally providing a distribution of output given an input x. We simply have, for all y [d], p(Y = y| X = x) = (g-softmax(g W,b(x)))y. Calibration of the geometric loss. We validate Prop. 5 experimentally on the ordinal regression dataset car. During training, we measure the geometric cross-entropy loss and the Hausdorff divergence on the train and validation set. Figure 3 shows that ℓΩis indeed an upper bound of DΩ, and that the difference between both terms reduces to almost 0 on the train set. Prop. 5 ensures this finding provided that the set of scoring function is large enough, which appears to be approximately the case here. Figure 3. Training curves for ordinal regression on dataset car. The difference between the g-logistic loss and the Hausdorff divergence vanishes on the train set. 5.2. Drawing generation with variational auto-encoders The proposed geometric loss and softmax are suitable to estimate distributions from inputs. As a proof-of-concept experiment, we therefore focus on a setting in which distributional output is natural: generation of hand-drawn doodles and digits, using the Google Quick Draw (Ha & Eck, 2018) and MNIST dataset. We train variational autoencoders on these datasets using, as output layers, (1) the KL divergence with normalized output and (2) our geometric loss with normalized output. These approaches output an image prediction using a softmax/g-softmax over all pixels, which is justified when we seek to output a concentrated distributional output. This is the case for doodles and digits, which can be seen as 1D distributions in a 2D space. It differs from the more common approach that uses a binary cross-entropy loss for every pixel and enables to capture interactions between pixels at the feature extraction level. We use standard KL penalty on the latent space distribution. Using the g-softmax takes into account a cost between pix- 0 50 100 0.0 softmax g-softmax g-softmax gen. softmax rec. softmax generation Figure 4. The g-softmax layer permits to generate and reconstruct drawing in a more concentrated manner. For a same level of variational penalty, the g-softmax better and faster minimizes the asymmetric Hausdorff divergence. See also Figure 6. els (i, j) and (k, l), that we set to be the Euclidean cost C/σ, where C is the ℓ2 2 cost and σ is the typical distance of interaction we choose σ = 2 in our experiments. We therefore made the hypothesis that it would help in reconstructing the input distributions, forming a non-linear layer that captures interaction between inputs in a nonparametric way. Results. We fit a simple MLP VAE on 28x28 images from the Quick Draw Cat dataset. Experimental details are reported in Appendix B (see Figure 6). We also present an experiment with 64x64 images and a DCGAN architecture, as well as visualization of a VAE fitted on MNIST. In Figure 4, we compare the reconstruction and the samples after training our model with the g-softmax and simple softmax loss. Using the g-softmax, which has a deconvolutional effect, yields images that are concentrated near the edges we want to reconstruct. We compare the training curves for both the softmax and g-softmax version: using the gsoftmax link function and its associated loss better minimizes the asymmetric Hausdorff divergence. The cost of computation is again increased by a factor 10. 6. Conclusion We introduced a principled way of learning distributional predictors in potentially continuous output spaces, taking into account a cost function in between inputs. We constructed a geometric softmax layer, that we derived from Fenchel conjugation theory in Banach spaces. The key to our construction is an entropy function derived from regularized optimal transport, convex and weak continuous on probability measures. Beyond the experiments in discrete measure spaces that we presented, our framework opens the doors for new applications that are intrinsically off-thegrid, such as super-resolution. Geometric Losses for Distributional Learning Acknowledgements The work of A. Mensch and G. Peyr e has been supported by the European Research Council (ERC project NORIA). A. Mensch thanks Jean Feydy and Thibault S ejourn e for fruitful discussions. Arjovsky, M., Chintala, S., and Bottou, L. Wasserstein generative adversarial networks. In Proceedings of the International Conference on Machine Learning, pp. 214 223, 2017. Aspert, N., Santa-Cruz, D., and Ebrahimi, T. Mesh: Measuring errors between surfaces using the hausdorff distance. In Proceedings of the IEEE International Conference on Multimedia and Expo, pp. 705 708, 2002. Bernhard, P. and Rapaport, A. On a theorem of Danskin with an application to a theorem of Von Neumann-Sion. Nonlinear Analysis: Theory, Methods & Applications, 24(8):1163 1181, 1995. Blondel, M., Martins, A. F. T., and Niculae, V. Learning classifiers with Fenchel-Young losses: Generalized entropies, margins, and algorithms. In Proceedings of the International Conference on Artificial Intelligence and Statistics, 2018. Blondel, M., Martins, A. F., and Niculae, V. Learning with Fenchel-Young losses. ar Xiv:1901.02324, 2019. Boyd, N., Schiebinger, G., and Recht, B. The alternating descent conditional gradient method for sparse inverse problems. SIAM Journal on Optimization, 27(2):616 639, 2017. Boyd, N., Jonas, E., Babcock, H. P., and Recht, B. Deep Loco: Fast 3D localization microscopy using neural networks. Bio Rxiv, pp. 267096, 2018. Bredies, K. and Pikkarainen, H. K. Inverse problems in spaces of measures. ESAIM: Control, Optimisation and Calculus of Variations, 19(1):190 218, 2013. Bregman, L. M. The relaxation method of finding the common point of convex sets and its application to the solution of problems in convex programming. USSR Computational Mathematics and Mathematical Physics, 7(3): 200 217, 1967. Ciliberto, C., Rosasco, L., and Rudi, A. A consistent regularization approach for structured prediction. In Advances in Neural Information Processing Systems, pp. 4412 4420, 2016. Courty, N., Flamary, R., Habrard, A., and Rakotomamonjy, A. Joint distribution optimal transportation for domain adaptation. In Advances in Neural Information Processing Systems, pp. 3730 3739, 2017. Crammer, K. and Singer, Y. On the algorithmic implementation of multiclass kernel-based vector machines. Journal of Machine Learning Research, 2:265 292, 2001. Cuturi, M. Sinkhorn distances: Lightspeed computation of optimal transport. In Advances in Neural Information Processing Systems, pp. 2292 2300, 2013. Cuturi, M. and Doucet, A. Fast computation of Wasserstein barycenters. In International Conference on Machine Learning, pp. 685 693, 2014. Cuturi, M. and Peyr e, G. Semi-dual regularized optimal transport. SIAM Review, 60(4):941 965, 2018. Danskin, J. M. The theory of max-min, with applications. SIAM Journal on Applied Mathematics, 14(4):641 664, 1966. Duchi, J. C., Khosravi, K., and Ruan, F. Multiclass classification, information, divergence, and surrogate risk. Annals of Statistics, 2018. Feydy, J. and Trouv e, A. Global divergences between measures: From Hausdorff distance to optimal transport. In Shape MI: Shape in Medical Imaging, 2019. Feydy, J., S ejourn e, T., Vialard, F.-X., Amari, S.-i., Trouv e, A., and Peyr e, G. Interpolating between optimal transport and MMD using Sinkhorn divergences. In Proceedings of the International Conference on Artifical Intelligence and Statistics, 2019. Frogner, C., Zhang, C., Mobahi, H., Araya, M., and Poggio, T. A. Learning with a Wasserstein loss. In Advances in Neural Information Processing Systems, pp. 2053 2061, 2015. Genevay, A., Cuturi, M., Peyr e, G., and Bach, F. Stochastic optimization for large-scale optimal transport. In Advances in Neural Information Processing Systems, pp. 3440 3448, 2016. Genevay, A., Peyr e, G., and Cuturi, M. Learning generative models with Sinkhorn divergences. In Proceedings of the International Conference on Artificial Intelligence and Statistics, 2018. Gimpel, K. and Smith, N. A. Softmax-margin CRFs: Training log-linear models with cost functions. In Proceedings of the North American Chapter of the Association for Computational Linguistics, 2010. Geometric Losses for Distributional Learning Gini, C. Variabilit a e Mutuabilit a. C. Cuppini, Bologna, 1912. Gutierrez, P. A., Perez-Ortiz, M., Sanchez-Monedero, J., Fernandez-Navarro, F., and Hervas-Martinez, C. Ordinal regression methods: Survey and experimental study. IEEE Transactions on Knowledge and Data Engineering, 28(1):127 146, 2016. Ha, D. and Eck, D. A neural representation of sketch drawings. In International Conference on Learning Representations, 2018. Kusner, M., Sun, Y., Kolkin, N., and Weinberger, K. From word embeddings to document distances. In Proceedings of the International Conference on Machine Learning, pp. 957 966, 2015. Liu, D. C. and Nocedal, J. On the limited memory BFGS method for large scale optimization. Mathematical Programming, 45(1-3):503 528, 1989. Luenberger, D. G. Optimization by vector space methods. John Wiley & Sons, 1997. Luise, G., Rudi, A., Pontil, M., and Ciliberto, C. Differential properties of Sinkhorn approximation for learning with Wasserstein distance. In Advances in Neural Information Processing Systems 31, pp. 5864 5874, 2018. Martins, A. F. T. and Astudillo, R. F. From Softmax to Sparsemax: A sparse model of attention and multi-label classification. Proceedings of the International Conference on Machine Learning, pp. 1614 1623, 2016. Mensch, A. and Blondel, M. Differentiable dynamic programming for structured prediction and attention. In Proceedings of the International Conference on Machine Learning, pp. 3462 3471, 2018. Mitter, S. K. Convex optimization in infinite dimensional spaces. In Recent Advances in Learning and Control, volume 371, pp. 161 179. Springer, 2008. Montavon, G., M uller, K.-R., and Cuturi, M. Wasserstein training of restricted Boltzmann machines. In Lee, D. D., Sugiyama, M., Luxburg, U. V., Guyon, I., and Garnett, R. (eds.), Advances in Neural Information Processing Systems 29, pp. 3718 3726. Curran Associates, Inc., 2016. Pedregosa, F., Bach, F., and Gramfort, A. On the consistency of ordinal regression methods. Journal of Machine Learning Research, 18(1):1769 1803, 2017. Radford, A., Metz, L., and Chintala, S. Unsupervised representation learning with deep convolutional generative adversarial networks. In International Conference on Learning Representations, 2016. Reid, M. D. and Williamson, R. C. Composite binary losses. Journal of Machine Learning Research, 11: 2387 2422, 2010. Rennie, J. D. and Srebro, N. Loss functions for preference levels: Regression with discrete ordered labels. In Proceedings of the IJCAI Multidisciplinary Workshop on Advances in Preference Handling, pp. 180 186, 2005. Rockafellar, R. T. Extension of Fenchel duality theorem for convex functions. Duke Mathematical Journal, 33 (1):81 89, 1966. Rockafellar, R. T. Convex Analysis. Princeton University Press, 1970. Rolet, A., Cuturi, M., and Peyr e, G. Fast dictionary learning with a smoothed Wasserstein loss. In Artificial Intelligence and Statistics, pp. 630 638, 2016. Santambrogio, F. Optimal transport for applied mathematicians. Birk auser, NY, 2015. Sriperumbudur, B. K., Fukumizu, K., and Lanckriet, G. R. G. Universality, Characteristic Kernels and RKHS Embedding of Measures. Journal of Machine Learning Research, 12:2389 2410, 2011. Sz ekely, G. J. and Rizzo, M. L. Energy statistics: A class of statistics based on distances. Journal of Statistical Planning and Inference, 143(8):1249 1272, 2013. Tewari, A. and Bartlett, P. L. On the consistency of multiclass classification methods. Learning Theory, 3559: 143 157, 2005. Tsochantaridis, I., Joachims, T., Hofmann, T., and Altun, Y. Large margin methods for structured and interdependent output variables. Journal of Machine Learning Research, 6:1453 1484, 2005. Villani, C. Optimal transport: Old and new. Springer, 2008. Wainwright, M. J. and Jordan, M. I. Graphical models, exponential families, and variational inference. Foundations and Trends in Machine Learning, 1(1 2):1 305, 2008. Weston, J. and Watkins, C. Support vector machines for multi-class pattern recognition. In Proceedings of the European Symposium on Artificial Neural Networks, pp. 219 224, 1999. Williamson, R. C., Vernet, E., and Reid, M. D. Composite multiclass losses. Journal of Machine Learning Research, 17(223):1 52, 2016.