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

Function sgd_entropic_regularization

ot/stochastic.py:463–534  ·  view source on GitHub ↗

r""" Compute the sgd algorithm to solve the regularized discrete measures optimal transport dual problem The function solves the following optimization problem: .. math:: \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + \mathrm{reg} \cdot\

(
    a, b, M, reg, batch_size, numItermax, lr, random_state=None
)

Source from the content-addressed store, hash-verified

461
462
463def sgd_entropic_regularization(
464 a, b, M, reg, batch_size, numItermax, lr, random_state=None
465):
466 r"""
467 Compute the sgd algorithm to solve the regularized discrete measures optimal transport dual problem
468
469 The function solves the following optimization problem:
470
471 .. math::
472 \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F +
473 \mathrm{reg} \cdot\Omega(\gamma)
474
475 s.t. \ \gamma \mathbf{1} = \mathbf{a}
476
477 \gamma^T \mathbf{1} = \mathbf{b}
478
479 \gamma \geq 0
480
481 Where :
482
483 - :math:`\mathbf{M}` is the (`ns`, `nt`) metric cost matrix
484 - :math:`\Omega` is the entropic regularization term with :math:`\Omega(\gamma)=\sum_{i,j} \gamma_{i,j}\log(\gamma_{i,j})`
485 - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target weights (sum to 1)
486
487 Parameters
488 ----------
489 a : ndarray, shape (ns,)
490 source measure
491 b : ndarray, shape (nt,)
492 target measure
493 M : ndarray, shape (ns, nt)
494 cost matrix
495 reg : float
496 Regularization term > 0
497 batch_size : int
498 size of the batch
499 numItermax : int
500 number of iteration
501 lr : float
502 learning rate
503 random_state : int, RandomState instance or None, default=None
504 Determines random number generation. Pass an int for reproducible
505 output across multiple function calls.
506
507 Returns
508 -------
509 alpha : ndarray, shape (ns,)
510 dual variable
511 beta : ndarray, shape (nt,)
512 dual variable
513
514 References
515 ----------
516 .. [19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. Large-scale Optimal Transport and Mapping Estimation. International Conference on Learning Representation (2018)
517 """
518
519 n_source = np.shape(M)[0]
520 n_target = np.shape(M)[1]

Callers 1

solve_dual_entropicFunction · 0.85

Calls 4

check_random_stateFunction · 0.85
batch_grad_dualFunction · 0.85
zerosMethod · 0.45
sqrtMethod · 0.45

Tested by

no test coverage detected