Analysis and Optimization of Loss Functions for Multiclass, Top-k, and Multilabel Classification
Maksim Lapin, Matthias Hein, Bernt Schiele
Introduction
Modern computer vision benchmarks are large scale , and are only likely to grow further both in terms of the sample size as well as the number of classes. While simply collecting more data may be a relatively straightforward exercise, obtaining high quality ground truth annotation is hard. Even when the annotation is just a list of image level tags, collecting a consistent and exhaustive list of labels for every image requires significant effort. Instead, existing benchmarks often offer only a single label per image, albeit the images may be inherently multilabel. The increased number of classes then leads to ambiguity in the labels as classes start to overlap or exhibit a hierarchical structure. The issue is illustrated in Figure 1, where it is difficult even for humans to guess the ground truth label correctly on the first attempt .
Allowing guesses instead of one leads to what we call the top- error, which is one of the main subjects of this work. While previous research is focused on minimizing the top- error, we consider . We are mainly interested in two cases: (i) achieving small top- error for all simultaneously; and (ii) minimization of a specific top- error. These goals are pursued in the first part of the paper which is concerned with single label multiclass classification. We propose extensions of the established multiclass loss functions to address top- error minimization and derive appropriate optimization schemes based on stochastic dual coordinate ascent (SDCA) . We analyze which of the multiclass methods are calibrated for the top- error and perform an extensive empirical evaluation to better understand their benefits and limitations. An earlier version of this work appeared in .
Moving forward, we see top- classification as a natural transition step between multiclass learning with a single label per training example and multilabel learning with a complete set of relevant labels. Multilabel learning forms the second part of this work, where we introduce a smoothed version of the multilabel SVM loss , and contribute two novel projection algorithms for efficient optimization of multilabel losses in the SDCA framework. Furthermore, we compare all multiclass, top-, and multilabel methods in a novel experimental setting, where we want to quantify the utility of multilabel annotation. Specifically, we want to understand if it is possible to obtain effective multilabel classifiers from single label annotation.
The contributions of this work are as follows.
In § 2, we provide an overview of the related work and establish connections to a number of related research directions. In particular, we point to an intimate link that exists between top- classification, label ranking, and learning to rank in information retrieval.
In § 3, we introduce the learning problem for multiclass and multilabel classification, and discuss the respective performance metrics. We also propose novel loss functions for minimizing the top- error and a novel smooth multilabel SVM loss. A brief summary of the methods that we consider is given in Table I.
In § 4, we introduce the notion of top- calibration and analyze which of the multiclass methods are calibrated for the top- error. In particular, we highlight that the softmax loss is uniformly top- calibrated for all .
In § 5, we develop efficient optimization schemes based on the SDCA framework. Specifically, we contribute a set of algorithms for computing the proximal maps that can be used to train classifiers with the specified multiclass, top-, and multilabel loss functions.
In § 6, the methods are evaluated empirically in three different settings: on synthetic data (§ 6.1), on multiclass datasets (§ 6.2), and on multilabel datasets (§ 6.3).
We release our implementation of SDCA-based solvers for training models with the loss functions considered in this work https://github.com/mlapin/libsdca. We also publish code for the corresponding proximal maps, which may be of independent interest.
Related Work
In this section, we place our work in a broad context of related research directions. First, we draw connections to the general problem of learning to rank. While it is mainly studied in the context of information search and retrieval, there are clear ties to multiclass and multilabel classification. Second, we briefly review related results on consistency and classification calibration. These form the basis for our theoretical analysis of top- calibration. Next, we focus on the technical side including the optimization method and the algorithms for efficient computation of proximal operators. Finally, we consider multiclass and multilabel image classification, which are the main running examples in this paper.
Learning to rank. Learning to rank is a supervised learning problem that arises whenever the structure in the output space admits a partial order . The classic example is ranking in information retrieval (IR), see e.g. for a recent review. There, a feature vector is computed for every query and every document , and the task is to learn a model that ranks the relevant documents for the given query before the irrelevant ones. Three main approaches are recognized within that framework: the pointwise, the pairwise, and the listwise approach. Pointwise methods cast the problem of predicting document relevance as a regression or a classification problem. Instead, the pairwise approach is focused on predicting the relative order between documents . Finally, the listwise methods attempt to optimize a given performance measure directly on the full list of documents , or propose a loss function on the predicted and the ground truth lists .
Different from ranking in IR, our main interest in this work is label ranking which generalizes the basic binary classification problem to multiclass, multilabel, and even hierarchical classification, see for a survey. A link between the two settings is established if we consider queries to be examples (e.g. images) and documents to be class labels. The main contrast, however, is in the employed loss functions and performance evaluation at test time (§ 3).
Top- classification in our setting is directly related to label ranking as the task is to place the ground truth label in the set of top labels as measured by their prediction scores. An alternative approach is suggested by who use structured learning to aggregate the outputs of pre-trained one-vs-all binary classifiers and directly predict a set of labels, where the labels missing from the annotation are modelled with latent variables. That line of work is pursued further in . The task of predicting a set of items is also considered in , who frame it as a problem of maximizing a submodular reward function. A probabilistic model for ranking and top- classification is proposed by , while use metric learning to train a nearest neighbor model. An interesting setting related to top- classification is learning with positive and unlabeled data , where the absence of a label does not imply it is a negative label, and also learning with label noise .
Label ranking is closely related to multilabel classification , which we consider later in this paper, and to tag ranking . Ranking objectives have been also considered for training convolutional architectures , most notably with a loss on triplets , that consideres both positive and negative examples. Many recent works focus on the top of the ranked list . However, they are mainly interested in search and retrieval, where the number of relevant documents by far exceeds what users are willing to consider. That setting suggests a different trade-off for recall and precision compared to our setting with only a few relevant labels. This is correspondingly reflected in performance evaluation, as mentioned above.
Consistency and calibration. Classification is a discrete prediction problem where minimizing the expected (0-1) error is known to be computationally hard. Instead, it is common to minimize a surrogate loss that leads to efficient learning algorithms. An important question, however, is whether the minimizers of the expected surrogate loss also minimize the expected error. Loss functions which have that property are called calibrated or consistent with respect to the given discrete loss. Consistency in binary classification is well understood , and significant progress has been made in the analysis of multiclass , multilabel , and ranking methods. In this work, we investigate calibration of a number of surrogate losses with respect to the top- error, which generalizes previously established results for multiclass methods.
While there exist efficient projection algorithms for optimizing the SVM hinge loss and its descendants, the situation is a bit more complicated for logistic regression, both binary and multiclass. There exists no analytical solution for an update with the logistic loss, and suggest a formula in the binary case which computes an approximate update in closed form. Multiclass logistic (softmax) loss is optimized in the SPAMS toolbox , which implements FISTA . Alternative optimization methods are considered in who also propose a two-level coordinate descent method in the multiclass case. Different from these works, we propose to follow closely the same variable fixing scheme that is used for SVM training and use the Lambert function in the resulting entropic proximal map. Our runtime compares favourably with SPAMS, as we show in § 6.2.
Image classification. Multiclass and multilabel image classification are the main applications that we consider in this work to evaluate the proposed loss functions. We employ a relatively simple image recognition pipeline following , where feature vectors are extracted from a convolutional neural network (ConvNet), such as the VGGNet or the ResNet , and are then used to train a linear classifier with the different loss functions. The ConvNets that we use are pre-trained on the large scale ImageNet dataset, where there is a large number of object categories (), but relatively little variation in scale and location of the central object. For scene recognition, we also use a VGGNet-like architecture that was trained on the Places 205 dataset.
Despite the differences between the benchmarks , image representations learned by ConvNets on large datasets have been observed to transfer well . We follow that scheme in single-label experiments, e.g. when recognizing birds and flowers using a network trained on ImageNet, or when transferring knowledge in scene recognition . However, moving on to multi-label classification on Pascal VOC and Microsoft COCO , we need to account for increased variation in scale and object placement.
While the earlier works ignore explicit search for object location , or require bounding box annotation , recent results indicate that effective classifiers for images with multiple objects in cluttered scenes can be trained from weak image-level annotation by explicitly searching over multiple scales and locations . Our multilabel setup follows closely the pipeline of with a few exceptions detailed in § 6.3.
Loss Functions for Classification
The rest of this section covers the technical background that is used later in the paper. We discuss our notation, introduce multiclass and multilabel classification, recall the standard approaches to classification, and introduce our recently proposed methods for top- error minimization.
In § 3.1, we discuss multiclass and multilabel performance evaluation measures that are used later in our experiments. In § 3.2, we review established multiclass approaches and introduce our novel top- loss functions; we also recall Moreau-Yosida regularization as a smoothing technique and compute convex conjugates for SDCA optimization. In § 3.3, we discuss multilabel classification methods, introduce the smooth multilabel SVM, and compute the corresponding convex conjugates. To enhance readability, we defer all the proofs to the appendix.
At test time, prediction depends on the evaluation metric and generally involves sorting / producing the top- highest scoring class labels in the multiclass setting, and predicting the labels that score above a certain threshold in multilabel classification. We come back to performance metrics shortly.
We use and to denote permutations of (indexes) . Unless stated otherwise, reorders components of a vector in descending order, . Therefore, for example, . If necessary, we make it clear which vector is being sorted by writing to mean and let . We also use the Iverson bracket defined as if is true and otherwise; and introduce a shorthand for the conditional probability . Finally, we let be obtained by removing the -th coordinate from .
Here, we briefly review performance evaluation metrics employed in multiclass and multilabel classification.
Multiclass. A standard performance measure for classification problems is the zero-one loss, which simply counts the number of classification mistakes . While that metric is well understood and inspired such popular surrogate losses as the SVM hinge loss, it naturally becomes more stringent as the number of classes increases. An alternative to the standard zero-one error is to allow guesses instead of one. Formally, the top- zero-one loss (top- error) is
That is, we count a mistake if the ground truth label scores below other class labels. Note that for we recover the standard zero-one error. Top- accuracy is defined as minus the top- error, and performance on the full test sample is computed as the mean across all test examples.
Multilabel. Several groups of multilabel evaluation metrics are established in the literature and it is generally suggested that multiple contrasting measures should be reported to avoid skewed results. Here, we give a brief overview of the metrics that we report and refer the interested reader to , where multilabel metrics are discussed in more detail.
Ranking based. This group of performance measures compares the ranking of the labels induced by to the ground truth ranking. We report the rank loss defined as
where is the set of reversely ordered pairs, and is the complement of . This is the loss that is implicitly optimized by all multiclass / multilabel loss functions that we consider since they induce a penalty when .
Finally, we report the standard Pascal VOC performance measure, mean average precision (mAP), which is computed as the one-vs-all AP averaged over all classes.
Let be the set of predicted labels for a given threshold , and let
be a set of primitives defined as in . Now, one can use any performance measure that is based on the binary confusion matrix, but, depending on where the averaging occurs, the following three groups of metrics are recognized.
Instance-averaging. The binary metrics are computed on the averages over labels and then averaged across examples:
Macro-averaging. The metrics are averaged across labels:
Micro-averaging. The metric is applied on the averages over both labels and examples:
Following , we consider the score as the binary metric with all three types of averaging. We also report multilabel accuracy, subset accuracy, and the hamming loss defined respectively as
where is the symmetric set difference.
2 Multiclass Methods
In this section, we switch from performance evaluation at test time to how the quality of a classifier is measured during training. In particular, we introduce the loss functions used in established multiclass methods as well as our novel loss functions for optimizing the top- error (1).
We also write instead of the full .
The OVA and multiclass methods were designed with the goal of minimizing the standard zero-one loss. Now, if we consider the top- error (1) which does not penalize mistakes, we discover that convexity of the above losses leads to phenomena where , but . That happens, for example, when , and creates a bias if we are working with rigid function classes such as linear classifiers. Next, we introduce loss functions that are modifications of the above losses with the goal of alleviating that phenomenon.
Moreau-Yosida regularization. We follow and give the main points here for completeness. The Moreau envelope or Moreau-Yosida regularization of the function is
where is the convex conjugate The convex conjugate of is . of . A classical result in convex analysis states that a conjugate of a strongly convex function has Lipschitz smooth gradient, therefore, is indeed a smooth function.
Top- hinge conjugate. Here, we compute the conjugates of the top- hinge losses and . As we show in , their effective domains The effective domain of is . are given by the top- simplex ( and respectively) of radius defined as
We let , , and note the relation where \Delta=\big{\{}x\nonscript\,|\nonscript\,\left\langle\mathbf{1},x\right\rangle\leq 1,\;x_{i}\geq 0\big{\}} is the unit simplex and the inclusions are proper for , while for all three sets coincide.
Let be the smoothing parameter. The smooth top- hinge loss () and its conjugate are
where is the Euclidean projection of onto . Moreover, is -smooth.
where is the identity matrix w/o the -th column, is the -th standard basis vector, and is the -dimensional vector of all ones. This follows from the definition of , the fact that can be written as for and , and a known result which says that for any closed convex set .
where \Delta=\big{\{}x\nonscript\,|\nonscript\,\left\langle\mathbf{1},x\right\rangle\leq 1,\;x_{j}\geq 0\big{\}} is the unit simplex.
If there is only a single such that , then even though is zero.
This problem is also present in all top- hinge losses considered above and is an inherent limitation due to their convexity. The origin of the problem is the fact that ranking based losses are based on functions such as
The function is convex if the sequence is monotonically non-increasing . This implies that convex ranking based losses have to put more weight on the highest scoring classifiers, while we would like to put less weight on them. To that end, we drop the first highest scoring predictions from the sum in (5), sacrificing convexity of the loss, and define the truncated top- entropy loss as follows
3 Multilabel Methods
Binary relevance (BR). Binary relevance is the standard one-vs-all scheme applied to multilabel classification. It is the default baseline for direct multilabel methods as it does not consider possible correlations between the labels.
Multilabel SVM. We follow the line of work by and consider the Multilabel SVM loss below:
In the multiclass setting, the set is singleton, therefore has no degrees of freedom and we recover the unit simplex over , as in (4). In the true multilabel setting, on the other hand, there is freedom to distribute the weight across all the classes in .
As with the smooth top- SVM, there is no analytic formula for the smoothed loss. However, we can both compute and optimize it within our framework by solving the Euclidean projection problem onto what we call a bipartite simplex. It is a convenient modification of the set above:
Let be the smoothing parameter. The smooth multilabel SVM loss and its conjugate are
where is the projection onto of b=\big{(}\tfrac{1}{2}-u_{y}\big{)}_{y\in Y}, \bar{b}=\big{(}\tfrac{1}{2}+u_{j}\big{)}_{j\in\bar{Y}}. is -smooth.
Assume that all the classes given in the ground truth set are equally likely. We define an empirical distribution for a given pair as , and model the conditional probability via the softmax:
The cross-entropy of the distributions and is given by
and the corresponding multilabel cross entropy loss is:
where and is the effective domain defined as:
Bayes Optimality and Top-k Calibration
This section is devoted to the theoretical analysis of multiclass losses in terms of their top- performance. We establish the best top- error in the Bayes sense, determine when a classifier achieves it, define the notion of top- calibration, and investigate which loss functions possess this property.
Bayes optimality. Recall that the Bayes optimal zero-one loss in binary classification is simply the probability of the least likely class . Here, we extend this notion to the top- error (1) introduced in § 3.1 for multiclass classification and provide a description of top- Bayes optimal classifier.
The Bayes optimal top- error at is
where . A classifier is top- Bayes optimal at if and only if
where .
Another way to write the optimal top- error is , which naturally leads to an optimal prediction strategy according to the ranking of in descending order. However, the description of a top- Bayes optimal classifier reveals that optimality for any given is better understood as a partitioning, rather than ranking, where the labels are split into and the rest, without any preference on the ranking in either subset. If, on the other hand, we want a classifer that is top- Bayes optimal for all simultaneously, a proper ranking according to is both necessary and sufficient.
Top- calibration. Optimization of the zero-one loss and the top- error leads to hard combinatorial problems. Instead of tackling a combinatorial problem directly, an alternative is to use a convex surrogate loss which upper bounds the discrete error. Under mild conditions on the loss function , an optimal classifier for the surrogate yields a Bayes optimal solution for the zero-one loss. Such loss functions are called classification calibrated, which is known in statistical learning theory as a necessary condition for a classifier to be universally Bayes consistent . We introduce now the notion of calibration for the top- error.
If a loss is not top- calibrated, it implies that even in the limit of infinite data, one does not obtain a classifier with the Bayes optimal top- error from Lemma 1. It is thus an important property, even though of an asymptotic nature. Next, we analyse which of the multiclass classification methods covered in § 3.2 are top- calibrated.
The OVA reduction is top- calibrated for any if the Bayes optimal function of a convex margin-based loss is a strictly monotonically increasing function of for every class .
Let the Bayes optimal classifier for the binary problem corresponding to a have the form
where is a strictly monotonically increasing function. The ranking of corresponds to the ranking of and hence the OVA reduction is top- calibrated for any . ∎
Next, we use Lemma 2 and the corresponding Bayes optimal classifiers to check if the one-vs-all schemes employing hinge and logistic regression losses are top- calibrated.
OVA logistic regression is top- calibrated.
The hinge loss is not calibrated since the corresponding binary classifiers, being piecewise constant, are subject to degenerate cases that result in arbitrary rankings of classes. Surprisingly, the smoothing technique based on Moreau-Yosida regularization (§ 3.2) makes a smoothed loss more attractive not only from the optimization side, but also in terms of top- calibration. Here, we show that a smooth binary hinge loss from fulfills the conditions of Lemma 2 and leads to a top- calibrated OVA scheme.
Multiclass SVM is not top- calibrated.
Multiclass softmax loss is top- calibrated.
The implicit reason for top- calibration of the OVA schemes and the softmax loss is that one can estimate the probabilities from the Bayes optimal classifier. Loss functions which allow this are called proper. We refer to and references therein for a detailed discussion.
Furthermore, convexity of the softmax and multiclass hinge losses leads to phenomena where , but . We discussed this issue § 3.2 and motivated modifications of the above losses for the top- error. Next, we show that one of the proposed top- losses is also top- calibrated.
The truncated top- entropy loss is top- calibrated for any .
Top- calibration of the remaining top- losses is an open problem, which is complicated by the absence of a closed-form expression for most of them.
Optimization Framework
In § 5.1, we state the primal and Fenchel dual optimization problems, and introduce the Lambert function. In § 5.2, we consider SDCA update steps and loss computation for multiclass methods, as well as present our runtime evaluation experiments. In § 5.3, we cover multilabel optimization and present our algorithm for the Euclidean projection onto the bipartite simplex.
We briefly recall the main facts about the SDCA framework , Fenchel duality , and the Lambert function .
where is the convex conjugate of and is interpreted as a set if is a multilabel loss.
It turns out that every update step is equivalent to the proximal operator The proximal operator, or the proximal map, of a function is defined as \operatorname{prox}_{f}(v)=\operatorname*{arg\,min}\limits_{x}\big{(}f(x)+\tfrac{1}{2}\left\|x-v\right\|^{2}\big{)}. of a certain function, which can be seen as a projection onto the effective domain of .
To develop intuition about the function , which is the Lambert function of the exponent, we look at how it behaves for different values of . An illustration is provided in Figure 2. One can see directly from the equation that the behavior of changes dramatically depending on whether is a large positive or a large negative number. In the first case, the linear part dominates the logarithm and the function is approximately linear; a better approximation is , when . In the second case, the function behaves like an exponent . To see this, we write and note that when , therefore, , if .
To compute , we use these approximations as initial points in a -th order Householder method . A single iteration of that method is already sufficient to get full float precision and at most two iterations are needed for double, which makes the function an attractive tool for computing entropic projections.
2 Multiclass Methods
In this section, we cover optimization of the multiclass methods from § 3.2 within the SDCA framework. We discuss how to efficiently compute the smoothed losses that were introduced via conjugation and do not have a closed-form expression. Finally, we evaluate SDCA convergence in terms of runtime and show that smoothing with Moreau-Yosida regularization leads to significant improvements in speed.
As mentioned in § 5.1 above, the core of the SDCA algorithm is the update step . Even the primal objective is only computed for the duality gap and could conceivably be omitted if the certificate of optimality is not required. Next, we focus on how the updates are computed for the different multiclass methods.
We show that performing the update step is equivalent to projecting a certain vector , computed from the prediction scores , onto the effective domain of , the top- simplex, with an added regularization , which biases the solution to be orthogonal to .
where , , and .
Smooth top- hinge losses converge significantly faster than their nonsmooth variants as we show in the scaling experiments below. This can be explained by the theoretical results of on the convergence rate of SDCA. They also had similar observations for the smoothed binary hinge loss.
where , , .
Problems (10) and (11) have similar structure, but the latter is considerably more difficult to solve due to the presence of logarithms. We propose to tackle this problem using the function introduced in § 5.1 above.
Our algorithm is an instance of the variable fixing scheme with the following steps: (i) partition the variables into disjoint sets and compute an auxiliary variable from the optimality conditions; (ii) compute the values of the variables using and verify them against a set of constraints (e.g. an upper bound in the top- simplex); (iii) if there are no violated constraints, we have computed the solution, and otherwise examine the next partitioning.
As we discuss in , there can be at most partitionings that we need to consider for and . To see this, let be a feasible point for (11), and define the subsets
Clearly, must hold, and we consider as a degenerate fall back case. Therefore, we are primarily interested in the partitions when . Due to monotonicity in the optimality conditions, one can show that always corresponds to the largest elements of the vector being projected. Hence, we start with an empty and add indexes of the largest ’s until the solution is found.
Next, we show how to actually compute and , given a candidate partition into and .
Let be the solution of (11) and let the sets and be defined for the given as in (12), then
and the variables , satisfy the nonlinear system
where , , is the inverse of .
Moreover, if is empty, then for all , and can be found from
Note that (15) is similar to (11) and we use a similar variable fixing scheme, as described above. However, this problem is much easier: the auxiliary variables and are computed directly without having to solve a nonlinear system, and their computation does not involve the function.
Let be the solution of (15) and let the sets and be defined for the given as in (12), then
and the variables , are computed from
where , , , and
3 Multilabel Methods
b=\rho\big{(}\tfrac{1}{2}-q_{y}\big{)}_{y\in Y_{i}}, \bar{b}=\rho\big{(}\tfrac{1}{2}+q_{j}\big{)}_{j\in\bar{Y}_{i}}, , and .
Euclidean projection onto the bipartite simplex . The optimization problem that we seek to solve is:
This problem has been considered by Shalev-Shwartz and Singer , who proposed a breakpoint searching algorithm based on sorting, as well as by Liu and Ye , who formulated it as a root finding problem that is solved via bisection. Next, we contribute a novel variable fixing algorithm that is inspired by the algorithm of Kiwiel for the continuous quadratic knapsack problem (a.k.a. projection onto simplex).
Initialization. Define the sets , , , , and solve the independent subproblems below using the algorithm of .
Let and be the resulting optimal thresholds, such that and . If , then is the solution to (17); stop.
and let , .
Stopping criterion. If , then the solution to (17) is given by and ; stop.
Variable fixing. If , update , . If , update , . Go to step 2.
The proposed algorithm is easy to implement, does not require sorting, and scales well in practice, as demonstrated by our experiments on VOC 2007 and MS COCO.
Runtime evaluation. We also compare the runtime of the proposed variable fixing algorithm and the sorting based algorithm of . We perform no comparison to as their code is not available. Furthermore, the algorithms that we consider are exact, while the method of is approximate and its runtime is dependent on the required precision. The experimental setup is the same as in § 5.2 above, and our results are reported in Table II.
, , b=\big{(}\tfrac{1}{\alpha}q_{j}+\tfrac{1}{k}\big{)}_{j\in Y_{i}}, \bar{b}=\big{(}\tfrac{1}{\alpha}q_{j}\big{)}_{j\in\bar{Y}_{i}}, and .
Moreover, the solution of (18) is given by
Experiments
This section provides a broad array of experiments on different datasets comparing multiclass and multilabel performance of the loss functions from § 3. We look at different aspects of empirical evaluation: performance on synthetic and real data, use of handcrafted features and the features extracted from a ConvNet, targeting a specific performance measure and being generally competitive over a range of metrics.
In this section, we demonstrate in a synthetic experiment that our proposed top- losses outperform the top- losses when the aim is optimal top- performance. The dataset with three classes is shown in the inner circle of Figure 4.
2 Multiclass Experiments
Please refer to Table I for an overview of the methods and our naming convention. Further comparison with other established ranking based losses can be found in .
Features. For ALOI, Letter, and News20 datasets, we use the features provided by the LibSVM datasets. For ALOI, we randomly split the data into equally sized training and test sets preserving class distributions. The Letter dataset comes with a separate validation set, which we use for model selection only. For News20, we use PCA to reduce dimensionality of sparse features from to preserving all non-singular PCA components Our SDCA-based solvers are designed for dense inputs..
For Caltech101 Silhouettes, we use the features and the train/val/test splits provided by .
For CUB, Flowers, FMD, and ImageNet 2012, we use MatConvNet to extract the outputs of the last fully connected layer of the VGGNet-16 model .
For Indoor 67, SUN 397, and Places 205, we perform the same feature extraction, but use the VGGNet-16 model of which was pre-trained on Places 205.
Discussion. The results are given in Table V, and we can make several interesting observations. First, while the OVA schemes perform quite similar to the multiclass approaches (OVA logistic regression vs. softmax, OVA SVM vs. multiclass SVM), which confirms earlier observations in , the OVA schemes performed worse on ALOI and Letter. Thus, we generally recommend the multiclass losses instead of the OVA schemes.
Comparing the softmax loss and multiclass SVM, we see that there is no clear winner in top- performance, but softmax consistently outperforms multiclass SVM in top- performance for . This might be due to the strong property of softmax being top- calibrated for all . Note that this trend is uniform across all datasets, in particular, also for the ones where the features are not coming from a ConvNet. Both the smooth top- SVM and the top- entropy losses perform slightly better than softmax if one compares specific top- errors. However, the good performance of the truncated top- entropy loss on synthetic data did not transfer to the real world datasets.
3 Multilabel Experiments
The aim of this section is threefold. First, we establish competitive performance of our multilabel classification methods from § 3.3 comparing them to the top methods from an extensive experimental study by Madjarov et al. on multilabel benchmark datasets of varying scale and complexity. Next, we discuss an interesting learning setting when top- classification methods emerge as a transition step between multiclass and multilabel approaches. Finally, we evaluate multiclass, top-, and multilabel classification methods on Pascal VOC 2007 and the more challenging Microsoft COCO image classification benchmarks.
We follow closely the evaluation protocol of except for the selection of the cut-off threshold (see § 3.1 for definition). Following , Madjarov et al. choose by matching label cardinality between the training and test data. While it is fast and easy to compute, that approach has two drawbacks: (i) being an instance of transductive learning, the method requires re-computation of every time test data changes; (ii) the choice of is not tuned to any performance measure and is likely to be suboptimal. In our experiments (not reported here), we observed generally comparable, but slightly lower results compared to when is selected on a validation set as discussed next.
Instead, Koyejo et al. recently showed that a consistent classifier is obtained when one computes by optimizing a given performance measure on a hold-out validation set. While there are at most distinct values of that would need to be considered, we limit the search to the grid of values.
Following , we use -fold cross-validation to select , the RBF kernel parameter , and the threshold , as described above. We use rather large and fine-grained grids both for (from to ) and (from to ). The smoothing parameter is always set .
Multiclass to multilabel. Collecting ground truth annotation is hard. Even when the annotation is simply an image level tag, providing a consistent and exhaustive list of labels for every image in the training set would require significant effort. It is much easier to provide a weaker form of annotation where only a single prominent object is tagged. An interesting question is then whether it is still possible to train multilabel classifiers from multiclass annotation. And if so, how large is the performance gap compared to methods trained with full multilabel annotation? In the following, we set to explore that setting and answer the questions above.
We also note that top- classification emerges naturally as an intermediate step between multiclass and multilabel learning. Recall that top- loss functions operate in the multiclass setting where there is a single label per example, but that label is hard to guess correctly on the first attempt. One could imagine that the example is actually associated with labels, but only a single label is revealed in the annotation. Therefore, it is also interesting to see if our top- loss functions can offer an advantage over the classic multiclass losses in this setting.
To evaluate the multiclass, top-, and multilabel loss functions on a common task, we choose two multilabel image classification benchmarks: Pascal VOC 2007 and Microsoft COCO. Multilabel methods are trained using full image level annotation (i.e. all class labels, but no bounding boxes or segmentation), while multiclass and top- methods are trained using a single label per image. Both datasets offer object level bounding box annotations which can be used to estimate relative sizes of objects in the scene. For multiclass training, we only keep the label of the largest object, which is our proxy to estimating the prominent object in the image. All methods are evaluated using full annotation at test time. Note that except for pruning the training labels, we do not use bounding boxes anywhere during training or testing.
To isolate the effect of loss functions on classifier training from feature learning, we follow the classic approach of extracting features as a pre-processing step and then train our classifiers on the fixed image representation. We use our own implementation of SDCA based solvers for all of the methods considered in this section. That offers strong convergence guarantees due to (i) convexity of the objective and (ii) having the duality gap as the stopping criterion.
Every feature vector can be mapped to a region in the original image. For training, we simply replicate the same image labels effectively increasing the size of the training set. At test time, we obtain a single ranking of class labels per image by max pooling the scores for each class. We follow this basic setup, but note that a improvement is possible with a more sophisticated aggregation of information from the different image regions .
Comparing the smooth and nonsmooth losses, we see that nonsmooth loss functions tend to perform better on this dataset. Moreover, SVM seems to perform significantly better than softmax. While this is a somewhat surprising result, it has been observed previously, e.g. with the R-CNN detector , and with deeply-supervised CNNs , even though their comparison was to OVA SVM.
The current state of the art classification results on COCO are reported in . A comparable architecture achieved mAP, while performing inference on the multiple regions per image and exploiting the bounding box annotations boosted the performance to mAP.
Conclusion
References
Appendix A Proofs from § 3
We take the convex conjugate of the top- hinge loss, which was derived in [9, Proposition 2], and add a regularizer to obtain the -strongly convex conjugate loss . Note that since and , we only need to work with -dimensional vectors where the -th coordinate is removed. The primal loss , obtained as the convex conjugate of , is -smooth due to a known result in convex analysis (see also [8, Lemma 2]). We now derive a formula to compute it based on the Euclidean projection onto the top- simplex. By definition,
For the constraint , we have
The final expression follows from the fact that
A.2 Proof of Proposition 3
Here, we use the notation as we need to take special care of the differences when computing the conjugate. Therefore, the softmax loss is
where as before and . Define
then and the convex conjugate is computed similar to [9, Lemma 2] as follows.
which together with implies
The function inside is concave and differentiable, hence the global optimum is at the critical point . Setting the partial derivatives to zero yields
for , from which we conclude, similar to [8, § 5.1], that and for all , i.e. . Let , we have at the optimum
Since , we also have that , hence
Summing and using the definition of ,
if and as stated in the proposition. ∎
A.3 Proof of Proposition 4
The convex conjugate of the top- entropy loss is
The (primal) top- entropy loss is defined as the convex conjugate of the above. We have
Note that , and hence the corresponding term vanishes. Finally, we let and .
Next, we discuss how this problem can be solved and show that it reduces to the softmax loss for . Let and consider an equivalent problem below.
Consider ’s for which holds at the optimum. The complementary slackness conditions imply that the corresponding . Let and re-define as . We obtain the simplified equations
If , then for all in a multiclass problem as discussed above, hence also . We have
Taking into account the minus in front of the in (20) and the definition of , we finally recover the softmax loss
A.4 Proof of Proposition 5
When the infimum is attained, the conjugate can be computed by solving the following optimization problem, otherwise the conjugate is . The corresponding dual variables are given on the right.
Computing the partial derivatives and setting them to zero,
After a basic derivation, we arrive at the solution of the dual problem given by
where must be in the following feasible set :
To complete the proof, note that if . ∎
A.5 Proof of Proposition 6
Before we add , recall that , and so \sum_{y\in Y}v_{y}=\frac{1}{2}\big{(}\operatorname{\textstyle\sum}_{y\in Y}v_{y}-\operatorname{\textstyle\sum}_{j\in\bar{Y}}v_{j}\big{)}. We use the average instead of an individual sum for symmetry and improved numerical stability. The smoothed conjugate loss is then
To derive the primal loss, we take the conjugate again:
Next, we define the following auxiliary variables:
and rewrite the smooth loss equivalently as
which is the Euclidean projection onto the set . ∎
A.6 Proof of Proposition 7
Let , then
Thus, for the supremum to be attained, we must have
which means if , and otherwise. Moreover, we have
Plugging the optimal , we compute the conjugate as
where and
This leads to the definition of the effective domain , since
Appendix B Proofs from § 4
The error is minimal when is maximal, which corresponds to taking the largest conditional probabilities and yields the Bayes optimal top- error at .
Since the relative order within is irrelevant for the top- error, any classifier , for which the sets and coincide, is Bayes optimal.
Note that we assumed w.l.o.g. that there is a clear cut between the most likely classes and the rest. In general, ties can be resolved arbitrarily as long as we can guarantee that the largest components of correspond to the classes (indexes) that yield the maximal sum and lead to top- Bayes optimality. ∎
B.2 Proof of Proposition 8
First, we show that the Bayes optimal function for the binary hinge loss is
Thus, one can compute the Bayes optimal classifier pointwise by solving
where . It is obvious that the optimal is contained in $$. We get
The minimum is attained at the boundary and we get
Therefore, the Bayes optimal classifier for the hinge loss is not a strictly monotonically increasing function of .
To show that OVA hinge is not top- calibrated, we construct an example problem with classes and , . Note that for every class , the Bayes optimal binary classifier is , hence the predicted ranking of labels is arbitrary and may not produce the Bayes optimal top- error. ∎
B.3 Proof of Proposition 9
First, we show that the Bayes optimal function for the binary logistic loss is
As above, the pointwise optimization problem is
The logistic loss is known to be convex and differentiable and thus the optimum can be computed via
which can be solved as \alpha^{*}=\log\Big{(}\frac{p_{1}(x)}{p_{-1}(x)}\Big{)} and leads to the formula for the Bayes optimal classifier stated above.
The derivative is strictly positive on , which implies that is strictly monotonically increasing. The logistic loss, therefore, fulfills the conditions of Lemma 2 and is top- calibrated for any . ∎
B.4 Proof of Proposition 10
In order to derive the smooth hinge loss, we first compute the conjugate of the standard binary hinge loss,
The corresponding primal smooth hinge loss is given by
is convex and differentiable with the derivative
We compute the Bayes optimal classifier pointwise.
Let , the optimal is found by solving
Case . Consider the case ,
This case corresponds to , which follows from the constraint . Next, consider ,
unless , which is already captured by the first case. Finally, consider . Then
where we have if . We obtain the Bayes optimal classifier for as follows:
Note that while is not a continuous function of for , it is still a strictly monotonically increasing function of for any .
Case . First, consider ,
From , we get the condition . Next, consider ,
which is in the range if . Finally, consider ,
where we have if . Overall, the Bayes optimal classifier for is
Note that is again a strictly monotonically increasing function of . Therefore, for any , the one-vs-all scheme with the smooth hinge loss (23) is top- calibrated for all by Lemma 2. ∎
B.5 Proof of Proposition 11
Suppose that the maximum of is not unique. In this case, we have
as the term is always active. The best possible loss is obtained by setting for all , which yields an expected loss of . On the other hand, if the maximum is unique and is achieved by , then
As the loss only depends on the gap , we can optimize this with .
As only the minimal enters the last term, the optimum is achieved if all are equal for (otherwise it is possible to reduce the first term without affecting the last term). Let for all . The problem becomes
Let . The solution is
Moreover, we have that the Bayes risk at is
It follows, that the multiclass hinge loss is not (top-) classification calibrated at any where as its Bayes optimal classifier reduces to a constant. Moreover, even if for some , the loss is not top- calibrated for as the predicted order of the remaining classes need not be optimal. ∎
B.6 Proof of Proposition 12
The multiclass softmax loss is (top-) calibrated for the zero-one error in the following sense. If
then for some and all
We now prove this result and show that it also generalizes to top- calibration for . Using the identity
As the loss is convex and differentiable, we get the global optimum by computing a critical point. We have
for . We note that the critical point is not unique as multiplication leaves the equation invariant for any . One can verify that satisfies the equations for any . This yields a solution
for any fixed . We note that is a strictly monotonically increasing function of the conditional class probabilities. Therefore, it preserves the ranking of and implies that is top- calibrated for any . ∎
B.7 Proof of Proposition 13
Therefore, the expected loss at can be written as
Note that the sum inside the logarithm does not depend on for . Therefore, a Bayes optimal classifier will have for all as then the first sum vanishes.
Let and , then
where and we used the rearrangement inequality. Therefore, the expected loss is minimized when and coincide (up to a permutation of the first elements), which already establishes top- calibration for all .
We can also derive a Bayes optimal classifier following the proof of Proposition 12. We have
A critical point is found by setting partial derivatives to zero for all , which leads to
We let if , and obtain finally
as a Bayes optimal classifier for any .
Note that preserves the ranking of for all in , hence, it is top- calibrated for all . ∎
Appendix C Proofs from § 5
We follow the proof of [9, Proposition 4]. Choose an and update to maximize
For the nonsmooth top- hinge loss, it was shown that
if and otherwise. Now, for the smoothed loss, we add regularization and obtain
with . Using and , one can simplify it to
and the feasibility constraint can be re-written as
For the regularization term , we have
We let and :
Now, we plug everything together and multiply with .
Collecting the corresponding terms finishes the proof. ∎
C.2 Proof of Proposition 15
Let and . Using Proposition 3,
where and . Let and . We have and from we get
where . Finally, we plug everything together as in Proposition 14. ∎
C.3 Proof of Proposition 16
Note that only and satisfy the above constraints, which implies and . We re-write the above as
These equations correspond to the Lambert function of the exponent, , discussed in § 5.1. Let and re-define .
Note that is a strictly monotonically increasing function, therefore, it is invertible and we can write
Next, we use the definition of the sets and ,
Let and , we get
Finally, we eliminate and obtain the system:
Moreover, when is empty, it simplifies into a single equation
C.4 Proof of Proposition 17
We continue the derivation started in the proof of Propostion 4. First, we write the system that follows directly from the KKT optimality conditions.
Next, we define the two index sets and as follows
Note that the set contains at most indexes corresponding to the largest components of . Now, we proceed with finding a that solves (24). Let . We eliminate as
Let , we write for
Let . We further write
which yields the following equation for
We note that: a) is readily computable once the sets and are fixed; and b) if since in that case. This yields the formula for as
As a sanity check, we note that we again recover the softmax loss for , since .
To verify that the computed and are compatible with the choice of the sets and , we check if this holds:
C.5 Proof of Proposition 18
where is a regularization parameter. Equivalently, we can divide both the primal and the dual objectives by and use as the regularization parameter instead. The optimization problem becomes
where the does not depend on . We ignore that constant in the following derivation and also define an auxiliary vector . Plugging the conjugate from Proposition 6 into (25), we obtain
We re-write the constraint as
and switch to the equivalent minimization problem below.
The final projection problem for the update step is
C.6 Proof of Proposition 19
We sketch the main parts of the proof that show correctness of the algorithm. A complete and formal derivation would follow the proof given in .
The Lagrangian for the optimization problem (17) is
and it leads to the following KKT conditions
If , the solution is trivial. Assume and let
where , are the dual variables from (27) and we have
and similar sets , for . Solving a reduced subproblem
for and a similar problem for , yields
We consider two cases: and . If , then we have two variables and to optimize over, but the optimization problem (17) decouples into two simplex projection problems which can be solved independently.
Let and be solutions to the independent problems (29). If , we have that the KKT conditions (27) are fulfilled and we have, therefore, the solution to the original problem (17). Otherwise, we have that the optimal and so at least one of the two variables must increase. Let , then , therefore .
If , then . We eliminate , which leads to
One can verify that if is computed by (30) and . Plugging (30) into (28), we get
One can further verify that and , where is computed by (31), , are computed by (28) with , and . Therefore, if for some , then , and so . The variables that were fixed to the lower bound while solving (29) with remain fixed when considering . ∎
C.7 Proof of Proposition 20
Let and , as before. We need to solve
Ignoring the constant terms and switching the sign, we obtain
Let and define
The final proximal problem for the update step is given as
Next, we discuss how to solve (18). The Lagrangian for this problem is given by
Setting the partial derivatives to zero, we obtain
We and , which implies and .
Let , we have
where is the Lambert function. Let
then the optimal is the root of , which corresponds to the constraint . ∎