Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Graphical tweaks for GWB + fixed seed method for the partial gromov test #376

Merged
merged 15 commits into from
May 11, 2022
Merged
3 changes: 1 addition & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

#### New features

- Added Generalized Wasserstein Barycenter solver + example (PR #372)
- Added Generalized Wasserstein Barycenter solver + example (PR #372), fixed graphical details on the example (PR #376)

#### Closed issues

- Fixed an issue where we could not ask TorchBackend to place a random tensor on GPU
(Issue #371, PR #373)


## 0.8.2

This releases introduces several new notable features. The less important
Expand Down
11 changes: 7 additions & 4 deletions examples/barycenters/plot_generalized_free_support_barycenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
# Input measures
sub_sample_factor = 8
I1 = pl.imread('../../data/redcross.png').astype(np.float64)[::sub_sample_factor, ::sub_sample_factor, 2]
I2 = pl.imread('../../data/tooth.png').astype(np.float64)[::sub_sample_factor, ::sub_sample_factor, 2]
I3 = pl.imread('../../data/heart.png').astype(np.float64)[::sub_sample_factor, ::sub_sample_factor, 2]
I2 = pl.imread('../../data/tooth.png').astype(np.float64)[::-sub_sample_factor, ::sub_sample_factor, 2]
I3 = pl.imread('../../data/heart.png').astype(np.float64)[::-sub_sample_factor, ::sub_sample_factor, 2]

sz = I1.shape[0]
UU, VV = np.meshgrid(np.arange(sz), np.arange(sz))
Expand Down Expand Up @@ -145,8 +145,11 @@ def _init():


def _update_plot(i):
ax.view_init(elev=i, azim=4 * i)
if i < 45:
ax.view_init(elev=0, azim=4 * i)
else:
ax.view_init(elev=i - 45, azim=4 * i)
return fig,


ani = animation.FuncAnimation(fig, _update_plot, init_func=_init, frames=90, interval=50, blit=True, repeat_delay=2000)
ani = animation.FuncAnimation(fig, _update_plot, init_func=_init, frames=136, interval=50, blit=True, repeat_delay=2000)
10 changes: 5 additions & 5 deletions test/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_partial_wasserstein():


def test_partial_gromov_wasserstein():
np.random.seed(42)
rng = np.random.RandomState(seed=42)
n_samples = 20 # nb samples
n_noise = 10 # nb of samples (noise)

Expand All @@ -150,11 +150,11 @@ def test_partial_gromov_wasserstein():
mu_t = np.array([0, 0, 0])
cov_t = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s)
xs = np.concatenate((xs, ((np.random.rand(n_noise, 2) + 1) * 4)), axis=0)
xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s, rng)
xs = np.concatenate((xs, ((rng.rand(n_noise, 2) + 1) * 4)), axis=0)
P = sp.linalg.sqrtm(cov_t)
xt = np.random.randn(n_samples, 3).dot(P) + mu_t
xt = np.concatenate((xt, ((np.random.rand(n_noise, 3) + 1) * 10)), axis=0)
xt = rng.randn(n_samples, 3).dot(P) + mu_t
xt = np.concatenate((xt, ((rng.rand(n_noise, 3) + 1) * 10)), axis=0)
xt2 = xs[::-1].copy()

C1 = ot.dist(xs, xs)
Expand Down