Learning a single model for multiple domains becomes a fundamental problem in machine learning and has found applications in cloud computing services. Cloud computing witnessed the development of machine learning in recent years. Apparently, users of these cloud computing services can benefit from sophisticated models provided by service carrier, e.g., Aliyun. However, the robustness of deployed models becomes a challenge due to the explosive popularity of the cloud computing services. Specifically, to maintain the scalability of the cloud computing service, only a single model will exist in the cloud for the same problem from different domains. For example, given a model for digits recognition in cloud, some users may call it to identify the handwritten digits while others may try to recognize the printed digits (e.g., house number).
A satisfied model has to deal with both domains (i.e., handwritten digits, printed digits) well in the modern architecture of cloud computing services. This problem is illustrated in Fig. 1. Note that the problem is different from multi-task learning [Zhang and Yang2017] that aims to learn different models (i.e., multiple models) for different tasks by exploiting the shared information between related tasks.
In a conventional learning procedure, an algorithm may mix the data from multiple domains by assigning an ad-hoc weight for each example, and then learn a model accordingly. The weight is pre-defined and can be uniform for each example, which is known as empirical risk minimization (ERM). Explicitly, the learned model can handle certain domains well but perform arbitrarily poor on the others. The unsatisfied performance in certain domains will result in business interruption from users. Moreover, assigning even weights for all examples can suffer from the data imbalance problem when the examples from certain domains dominate.
. Unlike the conventional strategy with the uniform distribution, it aims to optimize the performance of the model in the worst case distribution over examples. The learned model is explicitly more robust by focusing on the hard examples. To learn a robust model, many existing work apply the convex loss functions, while the state-of-the-art performance for several important practical problems are reported from the methods with non-convex loss functions, e.g, deep neural networks[He et al.2016, Krizhevsky, Sutskever, and Hinton2012, Szegedy et al.2015]. [Chen et al.2017] proposed an algorithm to solve the non-convex problem, but their analysis relies on a near-optimal oracle for the non-convex subproblem, which is not feasible for most non-convex problems in real tasks. Besides, their algorithm has to go through the whole data set at least once to update the parameters at every iteration, which makes it too expensive for the large-scale data set.
In this work, we propose a framework to learn a robust model over multiple domains rather than examples. By learning the model and the adversarial distribution simultaneously, the algorithm can balance the performance between different domains adaptively. Compared with the previous work, the empirical data distribution in each domain remains unchanged and our framework only learns the distribution over multiple domains. Therefore, the learned model will not be potentially misled by the adversarial distribution over examples. Our framework is also comparatively efficient due to the adoption of stochastic gradient descent (SGD) for optimization. More importantly, we first prove that the proposed method converges with a rate ofwithout the dependency on the oracle. To further improve the robustness of the framework, we introduce a regularizer for the adversarial distribution. We find that an appropriate regularizer not only prevents the model from a trivial solution but also accelerates the convergence rate to . The detailed theoretical results are summarized in Table 1. The empirical study on pets categorization and digits recognition demonstrates the effectiveness and efficiency of the proposed method.
Robust optimization has been extensively studied in the past decades [Bertsimas, Brown, and Caramanis2011]
. Recently, it has been investigated to improve the performance of the model in the worst case data distribution, which can be interpreted as regularizing the variance[Duchi, Glynn, and Namkoong2016]. For a set of convex loss functions (e.g., a single data set), [Namkoong and Duchi2016] and [Shalev-Shwartz and Wexler2016] proposed to optimize the maximal loss, which is equivalent to minimizing the loss with the worst case distribution generated from the empirical distribution of data. [Namkoong and Duchi2016] showed that for the -divergence constraint, a standard stochastic mirror descent algorithm can converge at the rate of for the convex loss. In [Shalev-Shwartz and Wexler2016], the analysis indicates that minimizing the maximal loss can improve the generalization performance. In contrast to a single data set, we focus on dealing with multiple data sets and propose to learn the non-convex model in this work.
To tackle non-convex losses, [Chen et al.2017] proposed to apply a near-optimal oracle. At each iteration, the oracle is called to return a near-optimal model for the given distribution. After that, the adversarial distribution over examples is updated according to the model from the oracle. With an -optimal oracle, authors proved that the algorithm can converge to the -optimal solution at the rate of , where is the number of iterations. The limitation is that even if we assume a near-optimal oracle is accessible for the non-convex problem, the algorithm is too expensive for the real-world applications. It is because that the algorithm has to enumerate the whole data set to update the parameters at each iteration. Without a near-optimal oracle, we prove that the proposed method can converge with a rate of with an appropriate regularizer and the computational cost is much cheaper.
Robust Optimization over Multiple Domains
Given domains, we denote the data set as . For the -th domain, , is an example (e.g., an image) and is the corresponding label. We aim to learn a model that performs well over all domains. It can be cast as a robust optimization problem as follows.
where is the parameter of a prediction model. is the empirical risk of the -th domain as
can be any non-negative loss function. Since the cross entropy loss is popular in deep learning, we will adopt it in the experiments.
The problem is equivalent to the following minimax problem
where . is an adversarial distribution over multiple domains and , where is the simplex as .
It is a game between the prediction model and the adversarial distribution. The minimax problem can be solved in an alternating manner, which applies gradient descent to learn the model and gradient ascent to update the adversarial distribution. Considering the large number of examples in each data set, we adopt SGD to observe an unbiased estimation for the gradient at each iteration, which avoids enumerating the whole data set. Specifically, at the-th iteration, a mini-batch of size is randomly sampled from each domain. The loss of the mini-batch from the -th domain is
It is apparent that and .
After sampling, we first update the model by gradient descent as
Then, the distribution is updated in an adversarial way. Since is from the simplex, we can adopt multiplicative updating criterion [Arora, Hazan, and Kale2012] to update it as
and we provide a high probability bound for completeness. All detailed proofs of this work can be found in the appendix.
Assume the gradient of and the function value are bounded as , , and . Let denote the results returned by Alg. 1 after iterations. Set the step-sizes as and . Then, with a probability , we have
where and is a constant.
Lemma 1 shows that the proposed method with the convex loss can converge to the saddle point at the rate of with high probability, which is a stronger result than the expectation bound in [Namkoong and Duchi2016]. Note that setting and will not change the order of the convergence rate, which means , and are not required for implementation.
Despite the extensive studies about the convex loss, there is little research about the minimax problem with non-convex loss. To provide the convergence rate for the non-convex problem, we first have the following lemma.
With the same assumptions as in Lemma 1, if is non-convex but -smoothness, we have
Since the loss is non-convex, the convergence is measured by the norm of the gradient (i.e., stationary point), which is a standard criterion for the analysis in the non-convex problem [Ghadimi and Lan2013]. Lemma 2 indicates that can converge to a stationary point where is a qualified adversary by setting the step-sizes elaborately. Furthermore, it demonstrates that the convergence rate of will be influenced by the convergence rate of via .
With Lemma 2, we have the convergence analysis of the non-convex minimax problem as follows.
With the same assumptions as in Lemma 2, if we set the step-sizes as and , we have
Compared with the convex case in Lemma 1, the convergence rate of a non-convex problem is degraded from to . It is well known that the convergence rate of general minimization problems with a smooth non-convex loss can be up to [Ghadimi and Lan2013]. Our results further demonstrate that minimax problems with non-convex loss is usually harder than non-convex minimization problems.
Different step-sizes can lead to different convergence rates. For example, if the step-size for updating is increased as and that for model is decreased as , the convergence rate of can be accelerated to while the convergence rate of will degenerate to . Therefore, if a sufficiently small step-size is applicable for , the convergence rate of can be significantly improved. We exploit this observation to enhance the convergence rate in the next subsection.
Regularized Non-convex Optimization
A critical problem in minimax optimization is that the formulation is very sensitive to the outlier. For example, if there is a domain with significantly worse performance than others, it will dominate the learning procedure according to Eqn.1 (i.e., one-hot value in ). Besides the issue of robustness, it is prevalent in real-world applications that the importance of domains is different according to their budgets, popularity, etc. Incorporating the side information into the formulation is essential for the success in practice. Given a prior distribution, the problem can be written as
where is the prior distribution which can be a distribution defined from the side information or a uniform distribution for robustness. defines the distance between two distributions, e.g., distance or -divergence
Since -divergence cannot handle the prior distribution with zero elements, optimal transportation (OT) distance becomes popular recently to overcome the drawback
For computational efficiency, we use the version with an entropy regularizer [Cuturi2013] and we have
Define the regularizer as
and it is convex in .
According to the duality theory [Boyd and Vandenberghe2004], for each , we can have the equivalent problem with a specified
Compared with the formulation in Eqn. 1, we introduce a regularizer for the adversarial distribution.
If is convex in , the similar convergence as in Theorem. 1 can be obtained with the same analysis. Moreover, according to the research for SGD, the strongly convexity is the key to achieve the optimal convergence rate [Rakhlin, Shamir, and Sridharan2012]. Hence, we adopt a strongly convex regularizer i.e., regularizer, for the distribution. The convergence rate for other strongly convex regularizers can be obtained with a similar analysis by defining the smoothness and the strongly convexity with the corresponding norm.
Equipped with the regularizer, the problem in Eqn. 5 can be solved with projected first-order algorithm. We adopt the projected gradient ascent to update the adversarial distribution as
projects the vectoronto the simplex. The projection algorithm can be found in [Duchi et al.2008] which is based on condition. We also provide the gradient of regularizer in the appendix.
Since the regularizer (i.e., ) is strongly concave, the convergence of can be accelerated dramatically, which leads to a better convergence rate for the minimax problem. The theoretical result is as follows.
With the same assumptions as in Theorem 1, if we assume and set step-sizes as and , we have
With the strongly concave regularizer, it is not surprise to obtain the convergence rate for . As we discussed in Lemma 2, a fast convergence rate of can improve that of . In Theorem 2, the convergence rate of is improved from to . It shows that the applied regularizer not only improves the robustness of the proposed framework but also accelerates the learning procedure.
Moreover, the step-size for the adversarial distribution provides a trade-off between the bias and variance of the gradient. Therefore, the convergence rate can be further improved by reducing the variance. We shrink the gradient with a factor and update the distribution as
When taking , the update becomes
With a similar analysis as Theorem 2, we have
With the same assumptions as in Theorem 2, if we set the step-size , we have
It shows that the constant can control the trade-off between bias (i.e., ) and variance (i.e., ). By setting the constant appropriately, we can have the following corollary
When setting , the RHS in Theorem 3 is maximum.
The optimality is from the fact that RHS is concave in and detailed discussion can be found in the appendix.
The algorithm for robust optimization with the regularizer is summarized in Alg. 2.
Trade Efficiency for Convergence
In this subsection, we study if we can recover the optimal convergence rate for the general non-convex problem as in [Ghadimi and Lan2013]. Note that [Chen et al.2017] applies a near-optimal oracle to achieve the convergence rate. Given a distribution, it is hard to observe an oracle for the non-convex model. In contrast, obtaining the near-optimal adversarial distribution with a fixed model is feasible. For the original problem in Eqn. 1, the solution is trivial as returning the index of the domain with the largest empirical loss. For the problem with the regularizer in Eqn. 5, the near-optimal can be obtained efficiently by any first order methods [Boyd and Vandenberghe2004]. Therefore, we can change the updating criterion for the distribution at the -th iteration to
With the new updating criterion and letting , we can have a better convergence rate as follows.
We conduct the experiments on training deep neural networks over multiple domains. The methods in the comparison are summarized as follows.
Individual: It learns the model from an individual domain.
Mixture: It learns the model from multiple domains with even weights, which is equivalent to fixing as an uniform distribution.
Mixture: It implements the approach proposed in Alg. 2 that learns the model and the adversarial distribution over multiple domains simultaneously.
We adopt the popular cross entropy loss as the loss function in this work. Deep models are trained with SGD and the size of each mini-batch is set to . For the methods learning with multiple domains, the number of examples from different domains are the same in a mini-batch and the size is . Compared with the strategy that samples examples according to the learned distribution, the applied strategy is deterministic and will not introduce extra noise. The method is evaluated by investigating the worst case performance among multiple domains. For the worst case accuracy, it is defined as . The worst case loss is defined as . All experiments are implemented on an NVIDIA Tesla P100 GPU.
First, we compare the methods on a fine-grained visual categorization task. Given the data sets of VGG cats&dogs [Parkhi et al.2012] and ImageNet [Russakovsky et al.2015], we extract the shared labels between them and then generate the subsets with desired labels from them, respectively. The resulting data set consists of 24 classes and the task is to assign the image of pets to one of these classes. For ImageNet, each class contains about images for training while that of VGG only has images. Therefore, we apply data augmentation by flipping (horizontal+vertical) and rotating () for VGG to avoid overfitting. After that, the number of images in VGG is similar to that of ImageNet. Some exemplar images from these data sets are illustrated in Fig. 5. We can find that the task in ImageNet is more challenging than that in VGG due to complex backgrounds.
We adopt ResNet18 [He et al.2016] as the base model in this experiment. It is initialized with the parameters learned from ILSVRC2012 [Russakovsky et al.2015] and we set the learning rate as for fine-tuning. Considering the small size of data sets, we also include the method of [Chen et al.2017] in comparison and it is denoted as Mixture. Since the near-optimal oracle is infeasible for Mixture, we apply the model with SGD iterations instead as suggested in [Chen et al.2017]. The prior distribution in the regularizer is set to the uniform distribution.
Fig. 2 summarizes the worst case training loss among multiple domains for the methods in the comparison. Since the performance of models learned from multiple domains is significantly better than those learned from an individual set, we illustrate the results in separate figures. Fig. 2 (a) compares the proposed method to those with the individual data set. It is evident that the proposed method has the superior performance and learning with an individual domain cannot handle the data from other domains well. Fig. 2 (b) shows the results of the methods learning with multiple data sets. First, we find that both Mixture and Mixture can achieve the lower worst case loss than Mixture, which confirms the effectiveness of the robust optimization. Second, Mixture performs best among all of these methods and it demonstrates that the proposed method can optimize the performance over the adversarial distribution. To investigate the discrepancy between the performances on two domains, we illustrate the result in Fig. 5. The discrepancy is measured by the difference between the empirical loss as . We can find that is smaller than at the beginning but decreases faster than . It is because the model is initialized with the parameters pre-trained on ImageNet. However, the task in VGG is easier than that in ImageNet, and drops faster after a few iterations. Compared with the benchmark methods, the discrepancy from the proposed method is an order of magnitude better throughout the learning procedure. It verifies the robustness of Mixture and also shows that the proposed method can handle the drifting between multiple domains well. Finally, to compare the performance explicitly, we include the detailed results in Table 2. Compared with the Mixture, we observe that Mixture can pay more attention to ImageNet than VGG and trade the performance between them.
To further demonstrate that Mixture can trade the performance effectively, we conduct the experiments with noisy data. We simulate each individual domain by adding the random Gaussian noise from to each pixel of the images from ImageNet pets. We vary the variance to generate the different domains and obtain two tasks where each has four domains with and , respectively. Fig. 6 compares the gap between the best and worst performance on different domains for Mixture and Mixture. First, we can find that the proposed method improves the worst-case performance significantly while keeping the best performance almost the same. Besides, domains can achieve the similar performance for the simple task with variance in . For the hard task that includes an extreme domain with noise from , the best performance is not sacrificed much due to the appropriate regularizer in Mixture.
After the comparison of performance, we illustrate the influence of the parameter in Fig. 7. The parameter can be found in Eqn. 5 and it constrains the distance of the adversarial distribution to the prior distribution. Besides the regularizer applied in Mixture, we also include the results of the regularizer defined in Proposition 1 and the method is denoted as Mixture. Fig. 7 (a) and (c) compare the discrepancy between the losses as in previous experiments. It is obvious that the smaller the , the smaller the gap between two domains. Fig. 7 (b) and (d) summarize the drifting in a distribution, which is defined as . Evidently, the learned adversarial distribution can switch adaptively according to the performance of the current model and the importance of multiple domains can be constrained well by setting appropriately.
Finally, we compare the running time in Fig. 5. Due to the lightweight update for the adversarial distribution, Mixture and Mixture have almost the same running time as Mixture. Mixture has to enumerate the whole data set after each SGD iterations to update the current distribution, hence, its running time with only complete iterations is nearly times slower than the proposed method with iterations on these small data sets.
In this experiment, we examine the methods on the task of digits recognition, which is to identify 10 digits (i.e., -) from images. There are two benchmark data sets for the task: MNIST and SVHN. MNIST [LeCun et al.1998] is collected for recognizing handwritten digits. It contains images for training and images for test. SVHN [Netzer et al.2011] is for identifying the house numbers from Google Street View images, which consists of training images and test images. Note that the examples in MNIST are gray images while those in SVHN are color images. To make the format consistent, we resize images in MNIST to be and repeat the gray channel in RGB channels to generate the color images. Considering the task is more straightforward than pets categorization, we apply the AlexNet [Krizhevsky, Sutskever, and Hinton2012] as the base model in this experiment and set the learning rate as . With a different deep model, we also demonstrate that the proposed framework can incorporate with various deep models.
Fig. 2 (c) and (d) show the comparison of the worst case training loss and Table 3 summarizes the detailed results. We can observe the similar conclusion as the experiments on pets categorization. Mixture can achieve good performance on these simple domains while the proposed method can further improve the worst case performance and provide a more reliable model for multiple domains.
In this work, we propose a framework to learn a robust model over multiple domains, which is essential for the service of cloud computing. The introduced algorithm can learn the model and the adversarial distribution simultaneously, for which we provide a theoretical guarantee on the convergence rate. The empirical study on real-world applications confirms that the proposed method can obtain a robust non-convex model. In the future, we plan to examine the performance of the method with more applications. Besides, extending the framework to multiple domains with partial overlapped labels is also important for real-world applications.
We would like to thank Dr. Juhua Hu from University of Washington Tacoma and anonymous reviewers for their valuable suggestions that help to improve this work.
- [Arora, Hazan, and Kale2012] Arora, S.; Hazan, E.; and Kale, S. 2012. The multiplicative weights update method: a meta-algorithm and applications. Theory of Computing 8(1):121–164.
- [Bertsimas, Brown, and Caramanis2011] Bertsimas, D.; Brown, D. B.; and Caramanis, C. 2011. Theory and applications of robust optimization. SIAM Review 53(3):464–501.
- [Boyd and Vandenberghe2004] Boyd, S., and Vandenberghe, L. 2004. Convex optimization. Cambridge university press.
- [Cesa-Bianchi and Lugosi2006] Cesa-Bianchi, N., and Lugosi, G. 2006. Prediction, learning, and games. Cambridge university press.
- [Chen et al.2017] Chen, R. S.; Lucier, B.; Singer, Y.; and Syrgkanis, V. 2017. Robust optimization for non-convex objectives. In NIPS, 4708–4717.
- [Cuturi2013] Cuturi, M. 2013. Sinkhorn distances: Lightspeed computation of optimal transport. In NIPS, 2292–2300.
- [Duchi et al.2008] Duchi, J. C.; Shalev-Shwartz, S.; Singer, Y.; and Chandra, T. 2008. Efficient projections onto the l-ball for learning in high dimensions. In ICML, 272–279.
- [Duchi, Glynn, and Namkoong2016] Duchi, J. C.; Glynn, P.; and Namkoong, H. 2016. Statistics of Robust Optimization: A Generalized Empirical Likelihood Approach. ArXiv e-prints.
- [Ghadimi and Lan2013] Ghadimi, S., and Lan, G. 2013. Stochastic first- and zeroth-order methods for nonconvex stochastic programming. SIAM Journal on Optimization 23(4):2341–2368.
- [He et al.2016] He, K.; Zhang, X.; Ren, S.; and Sun, J. 2016. Deep residual learning for image recognition. In CVPR, 770–778.
[Krizhevsky, Sutskever, and
Krizhevsky, A.; Sutskever, I.; and Hinton, G. E.
Imagenet classification with deep convolutional neural networks.In NIPS, 1106–1114.
- [LeCun et al.1998] LeCun, Y.; Bottou, L.; Bengio, Y.; and Haffner, P. 1998. Gradient-based learning applied to document recognition. Proceedings of the IEEE 86(11):2278–2324.
- [Namkoong and Duchi2016] Namkoong, H., and Duchi, J. C. 2016. Stochastic gradient methods for distributionally robust optimization with f-divergences. In NIPS, 2208–2216.
- [Nemirovski et al.2009] Nemirovski, A.; Juditsky, A.; Lan, G.; and Shapiro, A. 2009. Robust stochastic approximation approach to stochastic programming. SIAM Journal on Optimization 19(4):1574–1609.
- [Netzer et al.2011] Netzer, Y.; Wang, T.; Coates, A.; Bissacco, A.; Wu, B.; and Ng, A. Y. 2011. Reading digits in natural images with unsupervised feature learning. In NIPS workshop on deep learning and unsupervised feature learning, volume 2011, 5.
- [Parkhi et al.2012] Parkhi, O. M.; Vedaldi, A.; Zisserman, A.; and Jawahar, C. V. 2012. Cats and dogs. In CVPR.
- [Rakhlin, Shamir, and Sridharan2012] Rakhlin, A.; Shamir, O.; and Sridharan, K. 2012. Making gradient descent optimal for strongly convex stochastic optimization. In ICML.
- [Russakovsky et al.2015] Russakovsky, O.; Deng, J.; Su, H.; Krause, J.; Satheesh, S.; Ma, S.; Huang, Z.; Karpathy, A.; Khosla, A.; Bernstein, M.; Berg, A. C.; and Fei-Fei, L. 2015. ImageNet Large Scale Visual Recognition Challenge. IJCV 115(3):211–252.
- [Shalev-Shwartz and Wexler2016] Shalev-Shwartz, S., and Wexler, Y. 2016. Minimizing the maximal loss: How and why. In ICML, 793–801.
- [Szegedy et al.2015] Szegedy, C.; Liu, W.; Jia, Y.; Sermanet, P.; Reed, S. E.; Anguelov, D.; Erhan, D.; Vanhoucke, V.; and Rabinovich, A. 2015. Going deeper with convolutions. In CVPR, 1–9.
- [Zhang and Yang2017] Zhang, Y., and Yang, Q. 2017. A survey on multi-task learning. CoRR abs/1707.08114.
Proof of Lemma 1
According to the updating criterion, we have
where denotes the KL-divergence between the distribution and . Note that for , we have
Since , we have and
Take it back to Eqn. 8 and we have
Therefore, for the arbitrary distribution , we have
On the other hand, due to the convexity of the loss function, we have the inequality for the arbitrary model as
where we use with the fact that is the uniform distribution.
Note that , we have and . According to the Hoeffding-Azuma inequality for Martingale difference sequence [Cesa-Bianchi and Lugosi2006], with a probability , we have
By taking the similar analysis, with a probability , we have
Therefore, when setting and , with a probability , we have
where and are
Due to the convexity of in and concavity in , with a probability , we have
We finish the proof by taking the desired into the inequality. ∎
Proof of Lemma 2
We first present some necessary definitions.
A function is called -smoothness w.r.t. a norm if there is a constant such that for any and , it holds that
A function is called -strongly convex w.r.t. a norm if there is a constant such that for any and , it holds that
According to the -smoothness of the loss function, we have
So we have
Now we try to bound the difference between and
Proof of Theorem 2
Since is -strongly concave in , we have