Rémi Flamary

Professional website

Class Regularized Optimal Transport


Python toolbox for computing optimal transport with class regularization. This is the code that has been used for the numerical experiments in the paper:

N. Courty, R. Flamary, D. Tuia, "Domain adaptation with regularized optimal transport", European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML PKDD), 2014.

Abstract: We present a new and original method to solve the domain adaptation problem using optimal transport. By searching for the best transportation plan between the probability distribution functions of a source and a target domain, a non-linear and invertible transformation of the learning samples can be estimated. Any standard machine learning method can then be applied on the transformed set, which makes our method very generic. We propose a new optimal transport algorithm that incorporates label information in the optimization: this is achieved by combining an efficient matrix scaling technique together with a majoration of a non-convex regularization term. By using the proposed optimal transport with label regularization, we obtain significant increase in performance compared to the original transport solution. The proposed algorithm is computationally efficient and effective, as illustrated by its evaluation on a toy example and a challenging real life vision dataset, against which it achieves competitive results with respect to state-of-the-art methods.
author = {Courty, N. and Flamary, R. and Tuia, D.},
title = {Domain adaptation with regularized optimal transport},
booktitle = {European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML PKDD)},
editor = {},
year = {2014}


We provide regularized optimal transport solvers of the form:

where 29f6a062e393ea3584866f7cf7e8a332 is the convex set of matrices satisfying marginal d74b887520fe8fab712e3e7eba7ffcc9 and da31dea7350ec1804210209620cad8c7 and 1a0fa318ebc1b3fa6ffac01d86c286ce is a transportation cost matrix.

The regularization term e2fbf305721c3ef1bf86ea06fc39fab8 can be :

  • Classic LP transport: 8e2f055b8a81599d9b1996aa40f8ee89
  • Sinkhorn regularization : aab7020d806d44720fb862e4f3418140
  • Sinkhorn + Class regularization : da1f8a7e85f33f3f94d9f9e850c105aa


Python dependencies

  • Numpy, Matplotlib, Scipy
  • cvxopt

Download version 1.0 : transp_toolbox.zip

Short documentation

  • transport.py python module containing all the optimal transport solvers.

Entry points:

  • example_visu_tranport.py script illustrating the different OT approaches
  • run_vision_dataset loop for comparaing domain adaptation on the computer vision dataset


  • Marco Cuturi for providing us with the matlab version of Sinkhorn.