| * Joint OT matrix and mapping estimation [8]. | ||
| * Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). | ||
|
|
||
| * Gromov-Wasserstein distances [12] |
|
|
||
| [11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. | ||
|
|
||
| [12] Peyré, Gabriel, Marco Cuturi, and Justin Solomon, [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). 2016. |
| For demonstration purpose, we sample two Gaussian distributions in 2- and 3-dimensional spaces. | ||
| """ | ||
|
|
||
| n = 30 # nb samples |
…test function
| dissimilarity matrix | ||
| dim : Integer | ||
| dimension of the targeted space | ||
| maxIter : Maximum number of iterations of the SMACOF algorithm for a single run |
| Ct01 = [0 for i in range(2)] | ||
| for i in range(2): | ||
| Ct01[i] = ot.gromov.gromov_barycenters(N, [Cs[0], Cs[1]], [ | ||
| ps[0], ps[1]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3) |
| triangle = spi.imread('../data/triangle.png').astype(np.float64) / 256 | ||
| fleche = spi.imread('../data/coeur.png').astype(np.float64) / 256 | ||
|
|
||
| shapes = [carre, rond, triangle, fleche] |
Nicolas Courty added 2 commits
September 1, 2017 15:37
| square = spi.imread('../data/carre.png').astype(np.float64) / 256 | ||
| circle = spi.imread('../data/rond.png').astype(np.float64) / 256 | ||
| triangle = spi.imread('../data/triangle.png').astype(np.float64) / 256 | ||
| arrow = spi.imread('../data/coeur.png').astype(np.float64) / 256 |
| npos : ndarray, shape (R, dim) | ||
| Embedded coordinates of the interpolated point cloud (defined with one isometry) | ||
|
|
||
|
|
| """ | ||
| Sample two Gaussian distributions (2D and 3D) | ||
| ============================================= | ||
| The Gromov-Wasserstein distance allows to compute distances with samples that do not belong to the same metric space. |
| ===================================== | ||
| Gromov-Wasserstein Barycenter example | ||
| ===================================== | ||
| This example is designed to show how to use the Gromov-Wassertsein distance |
|
|
||
| def smacof_mds(C, dim, max_iter=3000, eps=1e-9): | ||
| """ | ||
| Returns an interpolated point cloud following the dissimilarity matrix C using SMACOF |
| Embedded coordinates of the interpolated point cloud (defined with one isometry) | ||
| """ | ||
|
|
||
| rng = np.random.RandomState(seed=3) |
| ---------- | ||
| p : ndarray, shape (N,) | ||
| weights in the targeted barycenter | ||
| lambdas : list of the S spaces' weights |
| sample weights in the S spaces | ||
| p : ndarray, shape(N,) | ||
| weights in the targeted barycenter | ||
| lambdas : list of the S spaces' weights |
| lambdas = np.asarray(lambdas, dtype=np.float64) | ||
|
|
||
| # Initialization of C : random SPD matrix | ||
| xalea = np.random.randn(N, 2) |