MCPcopy Create free account
hub / github.com/PythonOT/POT / test_init_duals

Function test_init_duals

test/test_ucoot.py:304–434  ·  view source on GitHub ↗
(nx, unbalanced_solver, divergence, eps)

Source from the content-addressed store, hash-verified

302 ),
303)
304def test_init_duals(nx, unbalanced_solver, divergence, eps):
305 n_samples = 5 # nb samples
306
307 mu_s = np.array([0, 0])
308 cov_s = np.array([[1, 0], [0, 1]])
309
310 xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s, random_state=4)
311 xt = xs[::-1].copy()
312
313 px_s, px_f = ot.unif(n_samples), ot.unif(2)
314 py_s, py_f = ot.unif(n_samples), ot.unif(2)
315
316 xs_nx, xt_nx = nx.from_numpy(xs, xt)
317 px_s_nx, px_f_nx, py_s_nx, py_f_nx = nx.from_numpy(px_s, px_f, py_s, py_f)
318
319 init_duals_samp = nx.from_numpy(np.zeros(n_samples), np.zeros(n_samples))
320 init_duals_feat = nx.from_numpy(np.zeros(2), np.zeros(2))
321 init_duals = (init_duals_samp, init_duals_feat)
322
323 reg_m = (10, 5)
324 alpha = (0.1, 0.2)
325 max_iter_ot = 5
326 max_iter = 5
327 tol = 1e-7
328 tol_ot = 1e-7
329
330 # test couplings
331 pi_sample, pi_feature = unbalanced_co_optimal_transport(
332 X=xs,
333 Y=xt,
334 wx_samp=px_s,
335 wx_feat=px_f,
336 wy_samp=py_s,
337 wy_feat=py_f,
338 reg_marginals=reg_m,
339 epsilon=eps,
340 divergence=divergence,
341 unbalanced_solver=unbalanced_solver,
342 alpha=alpha,
343 M_samp=None,
344 M_feat=None,
345 init_pi=None,
346 init_duals=None,
347 max_iter=max_iter,
348 tol=tol,
349 max_iter_ot=max_iter_ot,
350 tol_ot=tol_ot,
351 log=False,
352 verbose=False,
353 )
354
355 pi_sample_nx, pi_feature_nx = unbalanced_co_optimal_transport(
356 X=xs_nx,
357 Y=xt_nx,
358 wx_samp=px_s_nx,
359 wx_feat=px_f_nx,
360 wy_samp=py_s_nx,
361 wy_feat=py_f_nx,

Callers

nothing calls this directly

Calls 6

from_numpyMethod · 0.80
to_numpyMethod · 0.80
copyMethod · 0.45
zerosMethod · 0.45

Tested by

no test coverage detected