W ASSERSTEIN B ARYCENTER M ODEL E NSEMBLING
Anonymous authors
Paper under double-blind review
A BSTRACT
In this paper we propose to perform model ensembling in a multiclass or a multilabel learning setting using Wasserstein (W.) barycenters.
Optimal transport metrics, such as the Wasserstein distance, allow incorporating semantic side information such as word embeddings.
Using W. barycenters to ﬁnd the consensus between models allows us to balance conﬁdence and semantics in ﬁnding the agreement between the models.
We show applications of Wasserstein ensembling in attribute-based classiﬁcation, multilabel learning and image captioning generation.
These results show that the W. ensembling is a viable alternative to the basic geometric or arithmetic mean ensembling.
I NTRODUCTION
Model ensembling consists in combining many models into a stronger, more robust and more accurate model.
Ensembling is ubiquitous in machine learning and yields improved accuracies across multiple prediction tasks such as multi-class or multi-label classiﬁcation.
For instance in deep learning, output layers of Deep Neural Networks(DNNs), such as softmaxes or sigmoids, are usually combined using a simple arithmetic or geometric mean.
The arithmetic mean rewards conﬁdence of the models while the geometric means seeks the consensus across models.
What is missing in the current approaches to models ensembling, is the ability to incorporate side information such as class relationships represented by a graph or via an embedding space.
For example a semantic class can be represented with a ﬁnite dimensional vector in a pretrained word embedding space such as GloVe (Pennington et al., 2014).
The models’ predictions can be seen as deﬁning a distribution in this label space deﬁned by word embeddings: if we denote p i to be the conﬁdence of a model on a bin corresponding to a word having an embedding x i , the distribution on the label space is therefore p
= (cid:80) i p i δ x i .
In order to ﬁnd the consensus between many models predictions, we propose to achieve this consensus within this representation in the label space.
In contrast to arithmetic and geometric averaging, which are limited to the independent bins’ conﬁdence, this has the advantage of carrying the semantics to model averaging via the word embeddings.
More generally this semantic information can be encoded via cost a matrix C , where C ij encodes the dissimilarity between semantic classes i and j , and C deﬁnes a ground metric on the label space.
To achieve this goal, we propose to combine model predictions via Wasserstein (W.) barycenters (Agueh & Carlier, 2011), which enables us to balance the conﬁdence of the models and the semantic side information in ﬁnding a consensus between the models.
Wasserstein distances are a naturally good ﬁt for such a task, since they are deﬁned with respect to a ground metric in the label space of the models, which carry such semantic information.
Moreover they enable the possiblity of ensembling predictions deﬁned on different label sets, since the Wasserstein distance allows to align and compare those different predictions.
Since their introduction in (Agueh & Carlier, 2011)
W. barycenter computations were facilitated by entropic regularization (Cuturi, 2013) and iterative algorithms that rely on iterative Bregman projections (Benamou et al., 2015).
Many applications have used W. barycenters in Natural Language Processing (NLP), clustering and graphics.
We show in this paper that W. barycenters are effective in model ensembling and in ﬁnding a semantic consensus, and can be applied to a wide range of problems in machine learning (Table 1).
The paper is organized as follows:
In Section 2 we revisit geometric and arithmetic means from a geometric viewpoint, showing that they are (cid:96) 2 and Kullback Leibler divergence KL (extended KL divergence) barycenters respectively.
We give a brief overview of optimal transport metric and
W. barycenters in Section 3.
We highlight the advantages of W. barycenter ensembling in terms of semantic smoothness and diversity in Section 4.
Related work on W. barycenters in Machine learning are presented in Section 5.
Finally we show applications of Wasserstein ensembling on attribute based classiﬁcation, multi-label learning and image captioning in Section 6.
W ASSERSTEIN B ARYCENTERS FOR M ODEL E NSEMBLING
Normalized and Unnormalized predictions Ensembling.
In deep learning, predictions on a label space of ﬁxed size M are usually in one of two forms: a) normalized probabilities : in a multiclass setting, the neural network outputs a probability vector (normalized through softmax), where each bin corresponds to a semantic class; b) unnormalized positive scores : in a multi-label setting, the outputs of M independent logistic units are unnormalized positive scores, where each unit corresponds to the presence or the absence of a semantic class.
Model ensembling in those two scenarios has long history in deep learning and more generally in machine learning (Breiman, 1996; Freund & Schapire, 1999; Wolpert, 1992) as they lead to more robust and accurate models.
As discussed in the introduction, two methods have been prominent in model ensembling due to their simplicity: majority vote using the arithmetic mean of predictions, or consensus based using the geometric mean.
Revisiting Arithmetic and Geometric Means from a geometric viewpoint.
Given m predictions µ (cid:96) , and weights λ (cid:96) ≥ 0 such that (cid:80) m(cid:96) =
1 λ (cid:96) = 1 , the weighted arithmetic mean is given by ¯ µ a = (cid:80) m(cid:96)
=1 λ (cid:96) µ (cid:96) , and the weighted geometric mean by ¯ µ g = Π m(cid:96)
=1 ( µ λ (cid:96) (cid:96) ) .
It is instructive to reinterpret the arithmetic and geometric mean as weighted Frechet means (Deﬁnition 1)
(Zemel & Panaretos, 2017).
Deﬁnition 1.
[Weighted Frechet Mean]
Given a distance d and { ( λ (cid:96) , µ (cid:96) ) , λ (cid:96) > 0 , µ (cid:96) ∈ R M + } (cid:96) =1 ...m , the Frechet mean is deﬁned as follows: ¯ µ = arg min ρ (cid:80) m(cid:96)
=1 λ (cid:96) d
( ρ, µ (cid:96) ) .
It is easy to prove (Appendix F) that the arithmetic mean corresponds to a Frechet mean for d = (cid:107) .
(cid:107)
(the (cid:96) 2 Euclidean distance).
A less known fact is that the geometric mean corresponds to a
Frechet Mean for d = (cid:102) KL, where (cid:102) KL is the extended KL divergence to unnormalized measures: (cid:102) KL ( p, q ) =
(cid:80) i p i log (cid:16) p i q
i (cid:17) − p i + q i .
We give proofs and properties of arithmetic and geometric mean in Appendix F.
Following this geometric viewpoint, in order to incorporate the semantics of the target space in model ensembling, we need to use a distance d that takes advantage of the underlying geometry of the label space via a cost matrix C when comparing positive measures.
Optimal transport (OT) metrics such as Wasserstein- 2 have this property since they are built on an explicit cost matrix deﬁning pairwise distance between the semantic classes.
In this paper we propose to use the Frechet means with Wasserstein distance ( d = W 2 2 ) for model ensembling, i.e. use Wasserstein barycenters (Agueh & Carlier, 2011) for model ensembling:
[Equation]
Intuitively, the barycenter looks for a distribution ρ (a histogram ) that is close to all the base distributions µ (cid:96) in the Wasserstein sense.
In our context transporting the consensus ρ to each individual model µ (cid:96) should have a minimal cost, where the cost is deﬁned by the distance in the word embedding space.
W ASSERSTEIN B ARYCENTERS
Wasserstein distances were originally deﬁned between normalized probability vectors (Balanced
OT) (Villani, 2008; Peyr´e & Cuturi, 2017), but they have been extended to deal with unnormalized measures and this problem is referred to as unbalanced OT (Chizat et al., 2018; Frogner et al., 2015).
Motivated by the multi-class and the multi-label ensembling applications, in the following we present a brief overview of W. barycenters in the balanced and unbalanced cases.
3. O PTIMAL T RANSPORT M ETRICS
Balanced OT.
Given p ∈ ∆ N , where ∆ N = { p ∈ R N , p k ≥ 0 , (cid:80) Nk
=
1 p k = 1 } , p represents histograms on source label space Ω S
= { x i ∈ R d , i = 1 . . .
N } , for e.g words embeddings.
Consider similarly q ∈ ∆ M representing histograms whose bins are deﬁned on a target label space Ω T
= { y j ∈ R d , j = 1 . . .
M } .
Consider a cost function c ( x, y ) , (for example c ( x, y )
= (cid:107) x − y (cid:107) 2 ).
Let C be the matrix in ∈ R N × M such that C ij =
c ( x i , y j ) .
1 N denotes a vector with all ones.
Let γ ∈ R N × M be a coupling matrix whose marginals are p and q such that: γ ∈ Π( p, q ) = { γ ∈ R N × M , γ 1 M = p, γ (cid:62) 1 N = q } .
The optimal transport metric is deﬁned as follows:
[Equation]
When c ( x, y ) = (cid:107) x − y (cid:107) 22 , this distance corresponds to the so called Wasserstein − 2 distance W 22 .
Unbalanced OT.
When p and q are unnormalized and have different total masses, optimal transport metrics have been extended to deal with this unbalanced case.
The main idea is in relaxing the set Π( p, q ) using a divergence such as the extended KL divergence: (cid:102) KL.
(Chizat et al., 2018) deﬁne for λ >
the following generalized Wasserstein distance between unnormalized measures:
[Equation]
3. B ALANCED AND U NBALANCED W ASSERSTEIN IN M ODELS E NSEMBLING
Throughout the paper we consider m discrete prediction vectors µ (cid:96) ∈ R N (cid:96) + , (cid:96) = 1 . . .
m deﬁned on a discrete space (word embeddings for instance)
Ω S(cid:96)
=
{ x (cid:96)i ∈ R d , i = 1 . . .
N (cid:96) } .
We refer to Ω S(cid:96)
as source spaces.
Our goal is to ﬁnd a consensus prediction ¯ µ w ∈ R M + deﬁned on a discrete target space Ω T
= { y j ∈ R d , j = 1 . . .
M } .
Let C (cid:96) ∈
R N (cid:96) × M be the cost matrices, C (cid:96),i,j = c ( x (cid:96)i , y j ) .
Balanced W. Barycenters: Normalized predictions.
The W. barycenter (Agueh & Carlier, 2011) of normalized predictions is deﬁned as follows: ¯ µ w = arg min ρ (cid:80) m(cid:96)
=1 λ (cid:96) W ( ρ, µ (cid:96) ) , for the Wasserstein distance W deﬁned in equation (1).
Hence one needs to solve the following problem, for m coupling matrices γ (cid:96) , (cid:96) = 1 . . .
m :
[Equation]
Unbalanced W. Barycenters: Unnormalized predictions.
Similarly the W. barycenter of unnormalized predictions is deﬁned as follows: ¯ µ w = arg min ρ (cid:80) m(cid:96)
=1 λ (cid:96) W unb ( ρ, µ (cid:96) ) , for the Generalized Wasserstein distance W unb deﬁned in equation (2).
Hence the unbalanced W. barycenter problem (Chizat et al., 2018) amounts to solving , for m coupling matrices γ (cid:96) , (cid:96) = 1 . . .
m :
[Equation]
ρ
[Equation]
γ (cid:96) ,(cid:96)
[Equation] [Equation]
3. C OMPUTATION VIA E NTROPIC R EGULARIZATION AND P RACTICAL A DVANTAGES
Entropic Regularized Wasserstein Barycenters Algorithms.
The computation of the Wasserstein distance grows super-cubicly in the number of points.
This issue was alleviated by the introduction of the entropic regularization (Cuturi, 2013) to the optimization problem making it strongly convex.
Its solution can be found using scaling algorithms such as the so called Sinkhorn algorithm.
For any positive matrix γ , the entropy is deﬁned as follows:
H ( γ ) =
− (cid:80) ij γ ij (log( γ ij ) − 1) .
The entropic regularized OT distances in the balanced and unbalanced case become, for a hyperparameter ε > 0 :
[Equation]
[Table]
for ε → 0 , W ε and W unb ,ε converge to the original OT distance, and for higher value of ε we obtain the so called Sinkhorn divergence that allows for more diffuse transport between p and q .
Balanced and unbalanced W. barycenters can be naturally deﬁned with the entropic regularized OT distance as follows: min ρ (cid:80) m(cid:96)
=1 λ (cid:96) W ε ( ρ, µ (cid:96) ) and min ρ (cid:80) m(cid:96) =
1 λ (cid:96) W unb ,ε ( ρ, µ (cid:96) ) respectively.
This regularization leads to simple iterative algorithms (Benamou et al., 2015; Chizat et al., 2018) (for more details we refer the interested reader to (Chizat et al., 2018) and references therein) for computing W. barycenters that are given in Algorithms 1 and 2.
Algorithm 1: Balanced Barycenter for (Benamou et al., 2015)
Inputs: ε , C (cid:96) ( | source | × | target | ), λ (cid:96) , µ (cid:96)
Initialize
[Equation]
m for i = 1 . . .
Maxiter do
[Equation]
←
[Equation]
u (cid:96) (cid:96) = 1 . . .
m end for
Output: p
Ensembling (Chizat
Inputs: ε , C
[Table]
( | source | × | target | ), λ (cid:96) , λ , µ
[Table]
Initialize K [Table] = exp( − C
[Table]
/ε ) ,
[Table]
← 1 , ∀ (cid:96) = 1 . . .
m for i
= 1 . . .
Maxiter do
[Table]
end for
Output: p
We see that the output of Algorithm 1 is the geometric mean of K (cid:62)
[Table]
u (cid:96) , (cid:96) = 1 . . . m , where K (cid:96) is a Gaussian kernel with bandwidth ε the entropic regularization parameter.
Note v ∗ (cid:96) , (cid:96) = 1 . . .
m the values of v (cid:96) at convergence of Algorithm 1.
The entropic regularized W. barycenter can be written as follows:
[Equation]
[Table] (cid:96) (cid:17)(cid:17) . We see from this that K (cid:96) appears as matrix product multiplying individual models probability µ (cid:96) and the quantities v ∗ (cid:96) related to Lagrange multipliers.
This matrix vector product with K (cid:96) ensures probability mass transfer between semantically related classes i.e between items that has entries K (cid:96),ij with high values.
Remark 1 (The case K (cid:96) =
K = I ) .
As the kernel K in Algorithm 1 approaches I (identity) (this happens when ε → 0 ), the alternating Bregman projection of (Benamou et al., 2015) for balanced
W. barycenter converges to the geometric mean ¯ µ g = Π m(cid:96)
=1 ( µ (cid:96) )
λ (cid:96) .We prove this in Appendix D.
When K = I the ﬁxed point of Algorithm 1 reduces to geometric mean, and hence diverges from the W. barycenter.
Note that K approaches identity as ε → 0 , and in this case we don’t exploit any semantics.
Wasserstein Ensembling in Practice.
Table 1 gives a summary of machine learning tasks that can beneﬁt from Wasserstein Ensembling, and highlights the source and target domains as well as the corresponding kernel matrix K .
In the simplest case Ω S (cid:96) =
Ω T and N (cid:96) =
M for all (cid:96) , this corresponds to the case we discussed in multi-class and multi-labels ensemble learning, W. barycenters allows to balance semantics and conﬁdence in ﬁnding the consensus.
The case where source and target spaces are different is also of interest, we give here an application example in attribute based classiﬁcation : µ (cid:96) corresponds to prediction on a set of attributes and we wish to make predictions through the W. barycenter on a set of labels deﬁned with those attributes.
See Section 6.1. Table 12 in Appendix C gives other possible machine learning applications beyond the one explored in this paper. Appendix E discusses the computational complexity of Alg. 1 and 2.
T HEORETICAL A DVANTAGES OF W ASSERSTEIN B ARYCENTERS IN M ODELS E NSEMBLING
Smoothness of the Wasserstein Barycenter within Semantically Coherent Clusters.
In this section we consider Ω (cid:96)S = Ω T =
Ω , i.e the W. barycenters and all individual models are deﬁned on the same label space.
When we are ensembling models, one desiderata is to have an accurate aggregate model.
Smoothness and Diversity of the predictions of the ensemble is another desiderata as we often want to supply many diverse hypotheses.
In the context of sequence generation in language modeling such as image captioning, machine translation or dialog, this is very important [Table] as we use beam search on the predictions, diversity and smoothness of the predictions become key to the creativity and the composition of the sequence generator in order to go beyond “baby talk” and vanilla language based on high count words in the training set.
Hence we need to increase the entropy of the prediction by ﬁnding a semantic consensus whose predictions are diverse and smooth on semantically coherent concepts without compromising accuracy.
We will show in the following proposition that the W. barycenter allows such aggregation:
Proposition 1 (Properties of Wasserstein Barycenters) .
Let ν be the target distribution (an oracle) deﬁned on a discrete space
Ω
= { x 1 , . . .
x K , x j ∈ R d } (word embedding space) and µ (cid:96) , (cid:96) = 1 . . .
m be m estimates of ν .
Assume W 22 ( µ (cid:96) , ν ) ≤ ε (cid:96) .
The W. barycenter ¯ µ w of { µ (cid:96) } satisﬁes the following:
1) Semantic Accuracy (Distance to an oracle).
We have: W 22 (¯ µ w , ν ) ≤ 4 (cid:80) m(cid:96)
=
1 λ (cid:96) W 22 ( µ (cid:96) , ν ) .
Assume that W 22 ( µ (cid:96) , ν ) ≤ ε (cid:96) , then we have: W 22 (¯ µ w , ν ) ≤ 4 (cid:80) m(cid:96)
=1 λ (cid:96) ε
(cid:96) .
2) Diversity.
The diversity of the W. barycenter depends on the diversity of the models with respect to the Wasserstein distance (pairwise Wasserstein distance between models): W 22 (¯ µ w , µ k ) ≤ (cid:80) m(cid:96) (cid:54) =
k λ (cid:96) W 22 ( µ (cid:96) , µ k ) , ∀ k = 1 , . . .
m. 3)
Smoothness in the embedding space.
Deﬁne the smoothness energy E ( ρ ) = [Equation]
ij [-(cid:107) x i − x j (cid:107) 
-][Equation]
2 ρ i ρ j .
We have: E (¯ µ w ) ≤ (cid:80) m(cid:96)
=1 λ (cid:96) E ( µ (cid:96) ) .
The W. barycenter is smoother in the embedding space than the individual models.
4) Entropy .
Let H ( ρ ) = − (cid:80)
Ki =
1 ρ i log( ρ i ) , we have: H (¯ µ w ) ≥ (cid:80) m(cid:96)
=1 λ (cid:96) H ( µ (cid:96) ) .
Proof.
The proof is given in Appendix F.
We see from Proposition 1 that the W. barycenter preserves accuracy, but has a higher entropy than the individual models.
This entropy increase is due to an improved smoothness on the embedding space: words that have similar semantics will have similar probability mass assigned in the barycenter.
The diversity of the barycenter depends on the Wasserstein pairwise distance between the models: the W. barycenter output will be less diverse if the models have similar semantics as measured by the Wasserstein distance.
The proof of proposition 1 relies on the notion of convexity along generalized geodesics of the Wasserstein 2 distance (Agueh & Carlier, 2011).
Propositions 2 and 3 in Appendix F give similar results for geometric and arithmetic mean, note that the main difference is that the guarantees are given in terms of (cid:103) KL and (cid:96) 2 respectively, instead of W 2 .
In order to illustrate the diversity and smoothness of the W. barycenter, we give here a few examples of the W. barycenter on a vocabulary of size 10000 words, where the cost matrix is constructed from word synonyms ratings, deﬁned using Power Thesaurus or using GloVe word embeddings (Pennington et al., 2014).
We compute the W. barycenter (using Algorithm 1) between softmax outputs of 4 image captioners trained with different random seeds and objective functions.
Figureshows the W. barycenter as well as the arithmetic and geometric mean.
It can be seen that the W. barycenter has higher entropy and is smooth along semantics (synonyms or semantics in the GloVe space) and hence more diverse than individual models.
Table 2 shows top 15 words of barycenter, arithmetic and geometric means, from which we see that indeed the W. barycenter outputs clusters according to semantics.
In order to map back the words x j that have high probability in the W. barycenter to an individual model (cid:96) , we can use the couplings γ (cid:96) as follows: γ (cid:96)ij is the coupling between word j in the barycenter and word i in model (cid:96) .
Examples are given in supplement in Table 9. [Figure] [Table]
Controllable Entropy via Regularization.
As the entropic regularization parameter ε increases the distance of the kernel K from identity I increases and the entropy of the optimal couplings γ (cid:96) , ( H ( γ (cid:96) ) ) increases as well.
Hence the entropy of entropic regularized W. Barycenter is controllable via the entropic regularization parameter ε .
In fact since the barycenter can be written as ¯ µ w = γ (cid:62) (cid:96) 1 N (cid:96) , one can show that (Lemma 2 in Appendix):
[Equation]
As epsilon increases the right-hand side of the inequality increases and so does H (¯ µ w ) .
This is illustrated in Tables 3 and 8, we see that the entropy of the (entropic regularized) W. barycenter increases as the distance of the kernel K to identity increases ( (cid:107) K − I (cid:107) F increases as ε increases ) and the output of the W. barycenter remains smooth within semantically coherent clusters.
[Figure]
[Table]
-based similarity matrix K under different regularization ε (which controls the distance of K to identity I , (cid:107) K − I (cid:107) F ).
As ε decreases, (cid:107) K − I (cid:107) F also decreases, i.e., K approaches identity matrix, and the entropy of the output of Algorithm 1 decreases.
Note that the last column, corresponding to very small entropic regularization, coincides with the output from geometric mean in Figure 2 (for K
=
I , the Algorithm 1 outputs geometric mean as a barycenter).
R ELATED WORK
Wasserstein Barycenters in Machine Learning.
Optimal transport is a relatively new comer to the machine learning community.
The entropic regularization introduced in (Cuturi, 2013) fostered many applications and computational developments.
Learning with a Wasserstein loss in a multilabel setting was introduced in (Frogner et al., 2015), representation learning via the Wasserstein discriminant analysis followed in (Flamary et al., 2016).
More recently a new angle on generative adversarial networks learning with the Wasserstein distance was introduced in (Arjovsky et al., 2017;
Genevay et al., 2017; Salimans et al., 2018).
Applications in NLP were pioneered by the work on Word Mover Distance (WMD) on word embeddings of (Kusner et al., 2015).
Thanks to new algorithmic developments (Cuturi & Doucet, 2014; Benamou et al., 2015)
W. barycenters have been applied to various problems : in graphics (Solomon et al., 2015), in clustering (Ye et al., 2017), in dictionary learning (Schmitz et al., 2018), in topic modeling (Xu et al., 2018), in bayesian averaging (Rios et al., 2018), and in learning word and sentences embeddings (Muzellec & Cuturi, 2018;
Pal
Singh et al., 2018) etc.
Most of these applications of W. barycenter focus on learning balanced barycenters in the embedding space (like learning the means of the clusters in clustering), in our ensembling application we assume the embeddings given to us (such as GloVe word embedding ) and compute the barycenter at the predictions level.
Finally incorporating side information such as knowledge graphs or word embeddings in classiﬁcation is not new and has been exploited in diverse ways at the level of individual model training via graph neural networks (Marino et al., 2017; Deng et al., 2014), in the framework of W. barycenter we use this side information at the ensemble level.
A PPLICATIONS
In this Section we evaluate W. barycenter ensembling in the problems of attribute-based classiﬁcation, multi-label prediction and in natural language generation in image captioning.
6. A TTRIBUTE BASED C LASSIFICATION
As a ﬁrst simple problem we study object classiﬁcation based on attribute predictions.
We use
Animals with Attributes (Xian et al., 2017) which has 85 attributes and 50 classes.
We have in our experiments 2 attributes classiﬁers to predict the absence/presence of each of the 85 attributes independently, based on (1) resnet18 and (2) resnet34 (He et al., 2016) input features while training only the linear output layer (following the details in Section 6.2).
We split the data randomly in 30322 / 3500 / 3500 images for train / validation / test respectively.
We train the attribute classiﬁers on the train split.
Based on those two attributes detectors we would like to predict the 50 categories using unbalanced
W. barycenters using Algorithm 2.
Note that in this case the source domain is the set of theattributes and the target domain is the set of 50 animal categories.
For Algorithm 2 we use a columnnormalized version of the binary animal/attribute matrix as K matrix (85 × 50) , such that per animal the attribute indicators sum to 1.
We selected the hyperparameters ε = 0 .
3 and λ = 2 on the validation split and report here the accuracies on the test split. [Table]
As a baseline for comparison, we use arithmetic mean ( ¯ µ a ) and geometric mean ( ¯ µ g ) ensembling of the two attribute classiﬁers resnet18 and resnet34.
Then, using the same matrix K as above, we deﬁne the probability of category c (animal) as p ( c | µ ) =
K (cid:62) ¯ µ (for ¯ µ = ¯ µ a and ¯ µ g resp.).
We see from Table 4 that W. barycenter outperforms arithmetic and geometric mean on this task and shows its potential in attribute based classiﬁcation.
6. M ULTI - LABEL P REDICTION
For investigating W. barycenters on a multi-label prediction task, we use MS-COCO (Lin et al., 2014) with 80 objects categories.
MS-COCO is split into training ( ≈ 82K images), test ( ≈ 35K), and validation (5K) sets, following the Karpathy splits used in the community (Karpathy & Li, 2015b).
From the training data, we build a set of 8 models using ‘resnet18’ and ‘resnet50’ architectures (He et al., 2016).
To ensure some diversity, we start from pretrained models from either ImageNet (Deng et al., 2009) or Places365 (Zhou et al., 2017).
Each model has its last fully-connected (‘fc’) linear layer replaced by a linear layer allowing for 80 output categories.
All these pretrained models are ﬁne-tuned with some variations:
The ‘fc’ layer is trained for all models, some also ﬁne-tune the rest of the model, while some ﬁne-tune only the ‘layer4’ of the ResNet architecture.
These variations are summarized in Table 5.
Training of the ‘fc’ layer uses a 10 − 3 learning rate, while all ﬁne-tunings use 10 − 6 learning rate.
All multi-label trainings use ADAM (Kingma & Ba, 2015) with ( β 1 = 0 .
9 , β 2 = 0 .
for learning rate management and are stopped at 40 epochs.
Only the center crop of 224 ∗ 224 of an input image is used once its largest dimension is resized to 256. [Table]
Evaluation Metric.
We use the mean Average Precision (mAP) which gives the area under the curve of P = f ( R ) for precision P and recall R , averaged over each class.
mAP performs a sweep of the threshold used for detecting a positive class and captures a broad view of a multi-label predictor performance.
Performances for our 8 models are reported in Table 6.
Precision, Recall and F1 for micro/macro are given in Table 10.
Our individual models have reasonable performances overall.
[Table]
W
[Table]
outperforms
[Table] [Table] [Table]
Arithmetic and geometric means offer direct mAP improvements over our 8 individual models.
For unbalanced W. barycenter, the transport of probability mass is completely deﬁned by its matrix K = K (cid:96) in Algorithm 2.
We investigated multiple K matrix candidates by deﬁning K ( i, j ) as (i) the pairwise GloVe distance between categories, (ii) pairwise visual word2vec embeddings distance, (iii) pairwise co-occurence counts from training data.
In our experience, it is challenging to ﬁnd a generic K that works well overall.
Indeed, W. barycenter will move mass exactly as directed by K .
A generic K from prior knowledge may assign mass to a category that may not be present in some images at test time, and get harshly penalized by our metrics.
A successful approach is to build a diagonal K for each test sample based on the top-N scoring categories from each model and assign the average of model posteriors scores K ( i, i )
=
1 M (cid:80) m p m ( i | x ) for image x and category i .
If a category is not top scoring, a low K ( i, i ) =
ζ value is assigned to it, diminishing its contribution.
It gives W. barycenter the ability to suppress categories not deemed likely to be present, and reinforce the contributions of categories likely to be.
This simple diagonal K gives our best results when using the top-2 scoring categories per model (the median number of active class in our training data is about 2) and outperforms arithmetic and geometric means as seen in Table 6.
In all our experiments, W. barycenters parameters { ε, λ } in Algorithm 2 and ζ deﬁned above were tuned on validation set (5K).
We report results on MS-COCO test set ( ≈ 35K).
In this task of improving ourmodels, W. barycenter offers a solid alternative to commonly used arithmetic and geometric means.
Appendix B.2 shows that non-uniform weighting further improves W. ensembling performance.
6. I MAGE C APTIONING
In this task the objective is to ﬁnd a semantic consensus by ensembling 5 image captioner models.
The base model is an LSTM-based architecture augmented with the attention mechanism over the image.
In this evaluation we selected captioners trained with cross entropy objective as well as
GAN-trained models (Dognin et al., 2018).
The training was done on COCO dataset (Lin et al., 2014) using data splits from (Karpathy & Li, 2015a): training set of 113k images with 5 captions each, 5k validation set, and 5k test set.
The size of the vocabulary size is 10096 after pruning words with counts less than 5.
The matrix K (cid:96) =
K in Algorithm 1 was constructed using word similarities, deﬁned based on (i) GloVe word embeddings, so that K = exp( − C/ε ) , where cost matrix C is constructed based on euclidean distance between normalized embedding vectors; and (ii) synonym relationships, where we created K based on the word synonyms graph and user votes from Power Thesaurus.
The model prediction µ (cid:96) , for (cid:96) = 1 , . .
, 5 was selected as the softmax output of the captioner’s LSTM at the current time step, and each model’s input was weighted equally: λ (cid:96)
= 1 /m .
Once the barycenter p was computed, the result was fed into a beam search (beam size B = 5 ), whose output, in turn, was then given to the captioner’s LSTM and the process continued until a stop symbol (EOS) was generated.
In order to exploit the controllable entropy of W. barycenter via the entropic regualrization parameter ε , we also decode using randomized Beam search of (Shao et al., 2017), where instead of maintaining the top k values, we sample D candidates in each beam.
The smoothness of the barycenter in semantic clusters and its controllable entropy promotes diversity in the resulting captions.
We baseline the W. barycenter ensembling with arithmetic and geometric means.
Controllable entropy and diversity.
Figures 1 and 2 show the comparison of the ensembling methods on the validation set using topK and randomized beam search.
The x-axis shows (cid:107) K − I (cid:107) F , which corresponds to a different regularization ε (varied form 1 to 50 ).
We report two n-gram based metrics: CIDEr and SPICE scores, as well as the WMD (Word Mover Distance) similarity (Kusner et al., 2015), which computes the earth mover distance (the Wasserstein distance) between the generated and the ground truth captions using the GloVe word embedding vectors.
In topK beam search, as ε increases, causing the entropy to go up, the exact n-grams matching metrics, i.e., CIDEr and SPICE, deteriorate while WMD remains stable.
This indicates that while the barycenter-based generated sentences do not match exactly the ground truth, they still remain semantically close to it (by paraphrasing), as indicated by the stability of WMD similarity.
The results of the GloVe-based barycenter on the test split of COCO dataset are shown in Table 7.
In randomized beam search, the increase in entropy of the barycenter leads to a similar effect of paraphrasing but this works only up to a smaller value of ε , beyond which we observe a signiﬁcant deterioration of the results.
At that point all the words become neighbors and result in a very diffused barycenter, close to a uniform distribution.
This diffusion effect is smaller for the synonyms-based K since there are only a certain number of synonyms for each word, thus the maximum neighborhood is limited. [Table]
Robustness of W. Barycenter to Semantic Perturbations.
Finally, the right panel of Figure 2, shows the robustness of the W. barycenter to random shufﬂing of the µ (cid:96) values, within semantically coherent clusters.
Note that the size of those clusters increases as K moves away from identity.
The results show that barycenter is able to recover from those perturbations, employing the side information from K , while both the arithmetic and geometric means (devoid of such information) are confused by this shufﬂing, displaying a signiﬁcant drop in the evaluation metrics.
Human Evaluation. We performed human evaluation on Amazon MTurk on a challenging set of images out of context of MS-COCO (Dognin et al., 2018).
We compared three ensembling techniques: arithmetic, geometric and W. barycenter.
For W. barycenter we used the similarity matrix K deﬁned by visual word2vec (Kottur et al., 2016).
For the three models we use randomized beam search.
We asked MTurkers to give a score for each caption on a scale 1-5 and choose the best captions based on correctness and detailedness.
Captions examples are given in Fig. 6 (Appendix). Fig.
3 shows that W. barycenter has an advantage over the basic competing ensembling techniques [Figure]
C ONCLUSION
We showed in this paper that W. barycenters are effective in model ensembling in machine learning.
In the unbalanced case we showed their effectiveness in attribute based classiﬁcation, as well as in improving the accuracy of multi-label classiﬁcation.
In the balanced case, we showed that they promote diversity and improve natural language generation by incorporating the knowledge of synonyms or word embeddings.
A I MAGE C APTIONING
In this Section we provide additional results for evaluating the W. barycenter on image captioning task.
Figure 4 (which corresponds to Table 2 of the main paper), visualizes the word distribution of the considered ensembling methods for the input of 4 models.
It is clear that with a proper choice of similarity matrix K , W. barycenter can create diverse, high entropy outputs.
[Table]
{+00.95 parking 00.94train 00.20 vehicle 00.27 red 00.53 fashion 00.85 parking 00.94 buildin 00.88auto 00.19 photo 00.27 white 00.49 white 00.75 buildin 00.88 cars 00.81driving 00.19 red 00.21 automob 00.44 buildin 00.72 passeng 00.71 passeng 00.71photo 00.17 white 00.21 model 00.35 passeng 00.70 white 00.70 white 00.67suv 00.16 auto 00.21 buildin 00.35 model 00.54 model 00.59 model 00.60red 00.14 suv 00.21 silver 00.32 silver 00.45 picture 00.48 picture 00.49white 00.
+}
driving 00.21 pickup 00.30 city 00.44 silver 00.47 silver 00.47taxi 00.13 model 00.17 vehicle 00.29 picture 00.38 style 00.43 style 00.43pickup 00.11 pickup 00.17 suv 00.29 style 00.37 city 00.38 city 00.
Table 8 shows the effect of entropic regularization ε on the resulting distribution of the words of W. barycenter using GloVe embedding matrix.
As K moves closer to the identity matrix, the entropy of barycenter decreases, leading to outputs that are close/identical to the geometric mean.
On the other hand, with a large entropic regularization, matrix K moves away from identity, becoming an uninformative matrix of all 1 ’s. This eventually leads to a uniform distribution which spreads the probability mass equally across all the words.
This can be also visualized with a histogram in Figure 5, where the histograms on the bottom represent distributions that are close to uniform, which can be considered as failure cases of W. barycenter, since the image captioner in this case can only generate meaningless, gibberish captions.
In Table 9 we show a mapping from a few top words in the barycenter output (for similarity matrix
K based on synonyms) to the input models.
In other words, each column deﬁnes the words in the input models which have the greatest inﬂuence on each of top 3 words in the barycenter output.
In Figure 6 we present a few captioning examples showing qualitative difference between the considered ensembling techniques. [Figure] [Figure] [Figure]
[Table] [Table]
B M ULTI - LABEL P REDICTION B. M ETRICS USED AND S INGLE M ODELS P REDICTIONS
We evaluate our models using micro and macro versions of precision, recall, and F1-measure as covered in multi-label prediction metrics study from (Wu & Zhou, 2016).
For these measures, a threshold of 0.5 is commonly used to predict a label as positive in the community’s published results.
Macro precision is an average of per-class precisions while micro precision is computed by computing the ratio of all true positives across all image samples over the number of all positive classes in a dataset.
Therefore a macro (or per-class ) precision ‘P-C’ is deﬁned as 1 C (cid:80) i P i while a micro (or overall precision) ‘P-O’ is deﬁned as
[Equation]
i where TP i and FP i are true and false positives respectively.
Per-class and overall versions for R and F1 are deﬁned similarly.
We also employ mean Average Precision (mAP) which gives the area under the curve of P = f
( R ) averaged over each class.
Unlike P,R and F1, mAP inherently performs a sweep of the threshold used for detecting a positive class and captures a broader view of a multi-label predictor’s performance.
Performances for our 8 models and previously published results are reported in Table 10 and in
Table 6 in the paper.
Our models have reasonable performances overall.
[Table]
B. W EIGHTED M ULTI - LABEL P REDICTION E NSEMBLING
Ensembling results given in Tab. 6 are using uniformly weighted models, i.e. λ (cid:96)
= 1 m where m is the number of models.
However, in practice, arithmetic and geometric mean ensembling usually use weighted ensembles of models The weights are then optimized and established on a small validation set before being used for ensembling on a test set.
A well-known embodiment of this type of approach is Adaboost (Freund & Schapire, 1999) where weights are dynamically deﬁned at each pass of training wrt to the accuracy of base models. Here, we follow a much simpler but similar approach by deﬁning the performance of each model (cid:96) as the mean average precision (mAP (cid:96) ) on the validation set. mAP (cid:96) is used to deﬁne λ (cid:96) such that λ (cid:96) =
[Equation]
λ
[Equation]
are then applied to the models’ scores for arithmetic, geometric mean and
W.Barycenter ensemblings.
Tab.
11 reports mAP for each ensembling technique over the MS-COCO test set (35150 images).
Note that the λ (cid:96) weights deﬁnition is based on the ﬁnal metric evaluation, mAP in this case.
For other tasks such as classiﬁcation, accuracy or any other valid metric can be employed to compute the λ (cid:96) weights.
It must be noted that the weights are computed with respect to the ultimate performance metric at hand.
Tab.
11 reveals clearly that such approach of weighting models by their performance beneﬁts arithmetic and W.Barycenter ensembling for this task.
Both methods leverage the conﬁdence of the underlying models and the mAP weighting of models will reinforce the contributions of better performing models.
Geometric means ensembling is not signiﬁcantly impacted by non-uniform λ (cid:96) since it is mostly relying on consensus of the models, not their conﬁdence.
We conclude that weighting indeed helps performance and keeps a performance advantage for W. Barycenter over the alternatives arithmetic and geometric means.
[Table]
C O THER M ACHINE L EARNING T ASKS THAT CAN BE ADRESSED IN THE W ASSERSTEIN B ARYCENTER E NSEMBLING F RAMEWORK
Table 12 summarizes Machine learning tasks that could beneﬁt from W. Ensembling, especially in the case when source and target domains are distinct
[Table]
For W. Barycenters (Chizat et al., 2018) proves (in Theorem 4.1 of this paper ) that the ﬁxed point algorithm Given in Algorithms 1 and 2 converges under mild conditions on the matrix K : ( K takes positive values), nevertheless this does not characterize the convergence as ε goes to zero.
D. B ALANCED W. B ARYCENTERS
Γ convergence the regularized OT problem to the original OT problem when regularization vanishes was studied in (Carlier et al., 2017), but this work does provide an algorithm that guarantees such a convergence. For balanced W. barycenters we show in the following Lemma that the ﬁxed point of algorithmconverges to the geometric mean when K (cid:96) = I for all (cid:96) = 1 . . .
m .
Assuming C ij is bounded, it is easy to see that K converges to identity as ε approaches 0 . Hence the ﬁxed point of Algorithmdoes not recover the original unregularized W. Barycenter as ε → 0 . Lemma 1. For K (cid:96) =
I, (cid:96) = 1 . . .
m , the ﬁxed point of Algorithm 1 is the geometric mean ¯ µ g = Π m(cid:96)
=1 ( µ (cid:96) ) λ (cid:96) . Proof.
Let us show that at any iteration we have the following recurrence: [Equation]
all operations are element-wise. At iteration 0, the result holds since we have :
[Equation] Assume the result holds at time t . Let us prove it for t + 1 , following the updates of Algorithm 1 : [Equation]
since m
[Equation]
{+QED. For ε > 0 , Feydy et al (Feydy et al., 2018) showed recently that the Sinkhorn divergence deﬁnes an interpolation between the MMD distance (Maximum mean discrepancy (Gretton et al., 2012)) and the Wasserstein Distance. Hence for ε > 
 Algorithm 1 provides still an interesting solution that can be seen as an interpolation between the original (unregularized) Wasserstein Barycenter and the MMD Barycenter (Frechet barycenter for d = MMD ).+}
D. U NBALANCED W. B ARYCENTER
Note that
[Equation]
As λ goes to inﬁnity this unbalanced cost converges to the Hellinger distance:
[Equation]
Hence using d = 1 λ W unb,ε in Unbalanced Barycenters, we approach the Hellinger Frechet mean, as λ → ∞ .
E T IME C OMPLEXITY OF S CALING A LGORITHMS FOR W. B ARYCENTER E. C OMPUTATIONAL C OMPLEXITY AND I MPROVEMENTS
The total time complexity of a straight-forward implementation of Algorithms 1 and 2 is
O ( mN 2 Maxiter ) where Maxiter is the number of iterations, m the number of models and N the number of bins.
We make the following theoretical and practical remarks on how to improve this computational complexity to reach an almost linear dependency on N using low rank approximation of the kernel matrix K , and parallelization on m machines:
Dependency on Maxiter : For the number of iterations we found that Maxiter =5 is enough for convergence, which makes most of the computational complexity dependent on m and N . 2.
Dependency on N and low rank approximation : The main computational complexity comes from the matrix vector multiply K (cid:96) u (cid:96) that is of O ( N 2 ) .
Note that this complexity can be further reduced since the kernel matrix K is often low rank.
Therefore we can be written K = ΦΦ (cid:62) where Φ ∈ R N × k , where k (cid:28) N , which allows to compute this product as follows ΦΦ (cid:62) u (cid:96) that has a lower complexity
O
( Nk ) .
Φ can be computed using Nystrom approximation or random Fourier features.
Hence potentially on can get an algorithm with complexity O ( mNk ) , where k has a logarithmic dependency on N .
This was studied recently in (Altschuler et al., 2018).
Dependency on m and parallelization: Regarding the dependency on m , as noted in (Chizat et al., 2018; Benamou et al., 2015)
the algorithm is fully parallelizable which would lead to a computational complexity of O ( Nk ) by using simply m machines .
GPU and Batch version: Practically, the algorithm implemented takes advantage of matrix vector products’ speed on GPU.
The algorithm can be further accelerated by computing Sinkhorn divergences in batches as pointed in (Feydy et al., 2018).
E. T IME COMPLEXITY IN THE M ULTI - LABEL W ASSERSTEIN E NSEMBLING
We evaluated the time complexity of the GPU implementation of Wasserstein Barycenters in pytorch on our multi-label prediction experiments using MS-COCO test set (35150 samples).
Note that we used a vanilla implementation of Algorithm 2, i.e without parallelization, batching, or low rank approximation.
Results and comments for these wall clock timings can be found in Tab. 13.
As it can be observed, we need to use Maxiter = 5 on a GPU-V100 to reach below 4ms/image for
Wasserstein ensembling.
This is not a major overhead and can be further improved as discussed previously by using parallelization, batching and low rank approximation.
In Table 13, each timing was done over the whole test set; each timing repeated 5 times. We report means and standard deviations of total wall clock times for ensembling 8 models. Last column on the right is the average timing per image (in ms) for W.Barycenter. The number of W.Barycenter iterations (Maxiter) was varied from 1, 5 and 10 to show its impact.
We report timing numbers over two GPU architectures,
NVIDIA Tesla K80 and V100.
W.Barycenters leverage the GPU while Arithmetic and Geometric means do not.
Timings are of the computations of the means themselves, no data fetching or data preparation is included in these timings.
As expected, the wall clock time cost for W.Barycenters is several order of magnitude higher than for Arithmetic and Geometric means.
The difference of GPU does not impact the Arithmetic and Geometric means as they do not use it in our implementation.
The Barycenter computation see a speed up from K80 to V100 as V100 is much better at reducing wall time for longer number of iterations.
[Table]
F A DDITIONAL T HEORECTICAL R ESULTS AND P ROOFS
Proposition 2 (propreties of Geometric Mean) .
The following properties hold for geometric mean:
Geometric mean is the Frechet mean of (cid:102) KL.
The geometric mean is the Frechet mean with respect to the extended (cid:102) KL divergence:
[Equation]
Correctness guarantee of Geometric mean in (cid:102) KL.
Let ν be an oracle the geometric mean
satisﬁes:
[Equation]
Proposition 3 (properties of Arithmetic Mean) .
The following properties hold for geometric mean:
Arithmetic mean is the Frechet mean of (cid:96) 2 .
[Equation]
Correctness guarantee of Arithmetic mean in (cid:96) 2 .
Let ν be an oracle the arithmetic mean satisﬁes:
[Equation]
Entropy : Strong convexity of negative entropy with respect to (cid:96) 1 of arithmetic mean:
[Equation]
(cid:96)
[Equation]
Proof of Proposition 2. 1)
[Equation]
First order optimality condition:
[Equation]
This gives us the result:
[Equation]
[Table]
[Equation]
The last inequality follows from the arithmetic-geometric mean inequality (Jensen inequality):
[Equation]
Proof of Proposition 1. 1)
By the triangle inequality we have for all (cid:96) :
[Equation]
Raising to the power 2 we have:
[Equation]
µ
[Equation]
, ν )) , where we used ( a + b ) 2 ≤ 2( a 2 + b 2 ) .
Summing over all (cid:96) , and using (cid:80) m(cid:96)
=1 λ (cid:96) =
we have:
[Equation]
( By Barycenter deﬁnition
[Equation]
Using the symmetry of W 2 )
[Equation]
2) For a ﬁxed base distribution µ the functional W 22 ( ., µ ) is convex along generalized geodesics (Santambrogio, May 2015).
Given two distributions ν 1 , ν 2 , and T 1 and T 2 , such that T 1 , # µ = νand T 2 , # µ = ν 2 , we have:
[Equation]
Fix k ∈ [[1 , m ]] .
Note that there exists T k(cid:96) , (cid:96) = 1 . . .
m , such that ¯ µ w = (cid:0)(cid:80) (cid:96) λ (cid:96) T k(cid:96) (cid:1) # µ k , where
T k(cid:96), # µ k = µ (cid:96) .
Hence we have:
[Equation]
(cid:96)
[Equation] [Equation]
(cid:96) (cid:54)
[Equation]
k
[Equation]
(cid:96)
[Equation]
The smoothness energy is a valid interaction energy, by Proposition 7.7 Point 3 (for W = (cid:107)(cid:107) 2 ) (Agueh & Carlier, 2011), it is convex along generalized geodesics and hence by Proposition 7.6 it is barycenter convex:
[Equation]
The negative entropy ( − H ( ρ ) ) is a valid internal energy, by Proposition 7.7 Point 1 ( F ( t )
= − t log( t ) )
(Agueh & Carlier, 2011), it is convex along generalized geodesics and hence by Proposition 7.6 it is barycenter convex:
[Equation]
Remark 2 (Arithmetic mean and negative entropy) .
The negative entropy on discrete space is convex and moreover it is strongly convex with respect to the (cid:96) 1 norm hence we have:
[Equation]
hence the entropy of the arithmetic mean satisﬁes:
[Equation]
hence the diversity of the arithmetic mean depends on the (cid:96) 1 distance between the individual models, that does not take in count any semantics.
Remark 3.
Recall strong convexity of f in R d , there exists κ > 0 :
[Equation]
To show something about how the entropy of barycenter depends on pairwise distances we need something on “strong geodesic convexity” or “strong barycenter convexity” of negative entropy (Conjectured here):
[Equation]
and equivalently:
[Equation]
Note that this statement is true for a weaker notion of convexity that is displacement convexity and κ depends on Ricci curvature.
Lemma 2 (Entropic Regularized W. Barycenters: Controllable entropy via ε ) .
Assume that µ (cid:96) are such that µ (cid:96),i > 0 , for (cid:96) = 1 . . .
m , i = 1 . . .
M , we have:
[Equation]
Proof.
Let γ ∈ R N × M + be a coupling between p ∈ ∆ M and q ∈ ∆ N , q j > 0 we have: γ (cid:62) 1 N = p and γ 1 M = q , we have:
[Equation]
Let a i =
( γ ij q i ) j
=1 ...M .
Note that (cid:80)
Mj
=1 γ ij q i =
q i q i
= 1 , hence a i ∈ ∆ M .
Hence p can be written as a convex combination of probabilities:
[Equation]
Now the entropy of the convex combination is higher than convex combination of entropies (the entropy is concave):
[Equation]
Hence :
[Equation]
Hence :
[Equation]