View source: R/gromov_barycenter.R
| gwbary | R Documentation |
Computes the Gromov–Wasserstein (GW) barycenter of a collection of metric
measure spaces. Given a list of distance matrices {D^{(k)}}{k=1}^K
and their corresponding marginal distributions, the function estimates a
synthetic metric space whose intrinsic geometry best represents the input
collection under the GW criterion.
The GW barycenter is defined as the minimizer of a multi-measure Gromov–Wasserstein objective, where each dataset contributes according to a user-specified barycentric weight. Since the problem is jointly non-convex in the barycenter metric and the coupling matrices, the algorithm proceeds through an outer–inner iterative procedure.
gwbary(distances, marginals = NULL, weights = NULL, num_support = 100, ...)
distances |
a length- |
marginals |
marginal distributions for empirical measures; if |
weights |
weights for each individual measure; if |
num_support |
the number of support points |
... |
extra parameters including
|
A named list containing
an object of class dist representing the GW barycenter.
a length-M vector of barycenter weights with all entries being 1/M.
## Not run:
#-------------------------------------------------------------------
# Description
#
# GW barycenter computation is quite expensive. In this example,
# we draw a small set of empirical measures from the digit '3'
# images and compute their GW barycenter with a small number of
# support points. The attained barycenter distance matrix is then
# passed onto the classical MDS algorithm for visualization.
#-------------------------------------------------------------------
## GENERATE DATA
data(digits)
data_D = vector("list", length=5)
data_W = vector("list", length=5)
for (i in 1:5){
img_now = img2measure(digits3[[i]])
data_D[[i]] = stats::dist(img_now$support)
data_W[[i]] = as.vector(img_now$weight)
}
## COMPUTE
bary_dist <- gwbary(data_D, marginals=data_W, num_support=100)
bary_cmd2 <- stats::cmdscale(bary_dist$dist, k=2)
## VISUALIZE
opar <- par(no.readonly=TRUE)
par(pty="s")
plot(bary_cmd2, main="GW Barycenter Embedding",
xaxt="n", yaxt="n", pch=19, xlab="", ylab="")
par(opar)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.