1111
1212
1313def coordinate_grad_semi_dual (b , M , reg , beta , i ):
14- '''
14+ r '''
1515 Compute the coordinate gradient update for regularized discrete distributions for (i, :)
1616
1717 The function computes the gradient of the semi dual problem:
@@ -51,7 +51,7 @@ def coordinate_grad_semi_dual(b, M, reg, beta, i):
5151
5252 Examples
5353 --------
54-
54+ >>> import ot
5555 >>> n_source = 7
5656 >>> n_target = 4
5757 >>> reg = 1
@@ -63,8 +63,7 @@ def coordinate_grad_semi_dual(b, M, reg, beta, i):
6363 >>> Y_target = rng.randn(n_target, 2)
6464 >>> M = ot.dist(X_source, Y_target)
6565 >>> method = "ASGD"
66- >>> asgd_pi = stochastic.solve_semi_dual_entropic(a, b, M, reg,
67- method, numItermax)
66+ >>> asgd_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, numItermax)
6867 >>> print(asgd_pi)
6968
7069 References
@@ -84,7 +83,7 @@ def coordinate_grad_semi_dual(b, M, reg, beta, i):
8483
8584
8685def sag_entropic_transport (a , b , M , reg , numItermax = 10000 , lr = None ):
87- '''
86+ r '''
8887 Compute the SAG algorithm to solve the regularized discrete measures
8988 optimal transport max problem
9089
@@ -133,7 +132,7 @@ def sag_entropic_transport(a, b, M, reg, numItermax=10000, lr=None):
133132
134133 Examples
135134 --------
136-
135+ >>> import ot
137136 >>> n_source = 7
138137 >>> n_target = 4
139138 >>> reg = 1
@@ -145,8 +144,7 @@ def sag_entropic_transport(a, b, M, reg, numItermax=10000, lr=None):
145144 >>> Y_target = rng.randn(n_target, 2)
146145 >>> M = ot.dist(X_source, Y_target)
147146 >>> method = "ASGD"
148- >>> asgd_pi = stochastic.solve_semi_dual_entropic(a, b, M, reg,
149- method, numItermax)
147+ >>> asgd_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, numItermax)
150148 >>> print(asgd_pi)
151149
152150 References
@@ -176,7 +174,7 @@ def sag_entropic_transport(a, b, M, reg, numItermax=10000, lr=None):
176174
177175
178176def averaged_sgd_entropic_transport (a , b , M , reg , numItermax = 300000 , lr = None ):
179- '''
177+ r '''
180178 Compute the ASGD algorithm to solve the regularized semi continous measures optimal transport max problem
181179
182180 The function solves the following optimization problem:
@@ -223,7 +221,7 @@ def averaged_sgd_entropic_transport(a, b, M, reg, numItermax=300000, lr=None):
223221
224222 Examples
225223 --------
226-
224+ >>> import ot
227225 >>> n_source = 7
228226 >>> n_target = 4
229227 >>> reg = 1
@@ -235,8 +233,7 @@ def averaged_sgd_entropic_transport(a, b, M, reg, numItermax=300000, lr=None):
235233 >>> Y_target = rng.randn(n_target, 2)
236234 >>> M = ot.dist(X_source, Y_target)
237235 >>> method = "ASGD"
238- >>> asgd_pi = stochastic.solve_semi_dual_entropic(a, b, M, reg,
239- method, numItermax)
236+ >>> asgd_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, numItermax)
240237 >>> print(asgd_pi)
241238
242239 References
@@ -264,7 +261,7 @@ def averaged_sgd_entropic_transport(a, b, M, reg, numItermax=300000, lr=None):
264261
265262
266263def c_transform_entropic (b , M , reg , beta ):
267- '''
264+ r '''
268265 The goal is to recover u from the c-transform.
269266
270267 The function computes the c_transform of a dual variable from the other
@@ -303,7 +300,7 @@ def c_transform_entropic(b, M, reg, beta):
303300
304301 Examples
305302 --------
306-
303+ >>> import ot
307304 >>> n_source = 7
308305 >>> n_target = 4
309306 >>> reg = 1
@@ -315,8 +312,7 @@ def c_transform_entropic(b, M, reg, beta):
315312 >>> Y_target = rng.randn(n_target, 2)
316313 >>> M = ot.dist(X_source, Y_target)
317314 >>> method = "ASGD"
318- >>> asgd_pi = stochastic.solve_semi_dual_entropic(a, b, M, reg,
319- method, numItermax)
315+ >>> asgd_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, numItermax)
320316 >>> print(asgd_pi)
321317
322318 References
@@ -340,7 +336,7 @@ def c_transform_entropic(b, M, reg, beta):
340336
341337def solve_semi_dual_entropic (a , b , M , reg , method , numItermax = 10000 , lr = None ,
342338 log = False ):
343- '''
339+ r '''
344340 Compute the transportation matrix to solve the regularized discrete
345341 measures optimal transport max problem
346342
@@ -398,7 +394,7 @@ def solve_semi_dual_entropic(a, b, M, reg, method, numItermax=10000, lr=None,
398394
399395 Examples
400396 --------
401-
397+ >>> import ot
402398 >>> n_source = 7
403399 >>> n_target = 4
404400 >>> reg = 1
@@ -410,8 +406,7 @@ def solve_semi_dual_entropic(a, b, M, reg, method, numItermax=10000, lr=None,
410406 >>> Y_target = rng.randn(n_target, 2)
411407 >>> M = ot.dist(X_source, Y_target)
412408 >>> method = "ASGD"
413- >>> asgd_pi = stochastic.solve_semi_dual_entropic(a, b, M, reg,
414- method, numItermax)
409+ >>> asgd_pi = ot.stochastic.solve_semi_dual_entropic(a, b, M, reg, method, numItermax)
415410 >>> print(asgd_pi)
416411
417412 References
@@ -451,7 +446,7 @@ def solve_semi_dual_entropic(a, b, M, reg, method, numItermax=10000, lr=None,
451446
452447def batch_grad_dual (a , b , M , reg , alpha , beta , batch_size , batch_alpha ,
453448 batch_beta ):
454- '''
449+ r '''
455450 Computes the partial gradient of the dual optimal transport problem.
456451
457452 For each (i,j) in a batch of coordinates, the partial gradients are :
@@ -506,7 +501,7 @@ def batch_grad_dual(a, b, M, reg, alpha, beta, batch_size, batch_alpha,
506501
507502 Examples
508503 --------
509-
504+ >>> import ot
510505 >>> n_source = 7
511506 >>> n_target = 4
512507 >>> reg = 1
@@ -520,9 +515,7 @@ def batch_grad_dual(a, b, M, reg, alpha, beta, batch_size, batch_alpha,
520515 >>> X_source = rng.randn(n_source, 2)
521516 >>> Y_target = rng.randn(n_target, 2)
522517 >>> M = ot.dist(X_source, Y_target)
523- >>> sgd_dual_pi, log = stochastic.solve_dual_entropic(a, b, M, reg,
524- batch_size,
525- numItermax, lr, log)
518+ >>> sgd_dual_pi, log = ot.stochastic.solve_dual_entropic(a, b, M, reg, batch_size, numItermax, lr, log)
526519 >>> print(log['alpha'], log['beta'])
527520 >>> print(sgd_dual_pi)
528521
@@ -548,7 +541,7 @@ def batch_grad_dual(a, b, M, reg, alpha, beta, batch_size, batch_alpha,
548541
549542
550543def sgd_entropic_regularization (a , b , M , reg , batch_size , numItermax , lr ):
551- '''
544+ r '''
552545 Compute the sgd algorithm to solve the regularized discrete measures
553546 optimal transport dual problem
554547
@@ -597,7 +590,7 @@ def sgd_entropic_regularization(a, b, M, reg, batch_size, numItermax, lr):
597590
598591 Examples
599592 --------
600-
593+ >>> import ot
601594 >>> n_source = 7
602595 >>> n_target = 4
603596 >>> reg = 1
@@ -611,9 +604,7 @@ def sgd_entropic_regularization(a, b, M, reg, batch_size, numItermax, lr):
611604 >>> X_source = rng.randn(n_source, 2)
612605 >>> Y_target = rng.randn(n_target, 2)
613606 >>> M = ot.dist(X_source, Y_target)
614- >>> sgd_dual_pi, log = stochastic.solve_dual_entropic(a, b, M, reg,
615- batch_size,
616- numItermax, lr, log)
607+ >>> sgd_dual_pi, log = ot.stochastic.solve_dual_entropic(a, b, M, reg, batch_size, numItermax, lr, log)
617608 >>> print(log['alpha'], log['beta'])
618609 >>> print(sgd_dual_pi)
619610
@@ -644,7 +635,7 @@ def sgd_entropic_regularization(a, b, M, reg, batch_size, numItermax, lr):
644635
645636def solve_dual_entropic (a , b , M , reg , batch_size , numItermax = 10000 , lr = 1 ,
646637 log = False ):
647- '''
638+ r '''
648639 Compute the transportation matrix to solve the regularized discrete measures
649640 optimal transport dual problem
650641
@@ -695,7 +686,7 @@ def solve_dual_entropic(a, b, M, reg, batch_size, numItermax=10000, lr=1,
695686
696687 Examples
697688 --------
698-
689+ >>> import ot
699690 >>> n_source = 7
700691 >>> n_target = 4
701692 >>> reg = 1
@@ -709,9 +700,7 @@ def solve_dual_entropic(a, b, M, reg, batch_size, numItermax=10000, lr=1,
709700 >>> X_source = rng.randn(n_source, 2)
710701 >>> Y_target = rng.randn(n_target, 2)
711702 >>> M = ot.dist(X_source, Y_target)
712- >>> sgd_dual_pi, log = stochastic.solve_dual_entropic(a, b, M, reg,
713- batch_size,
714- numItermax, lr, log)
703+ >>> sgd_dual_pi, log = ot.stochastic.solve_dual_entropic(a, b, M, reg, batch_size, numItermax, lr, log)
715704 >>> print(log['alpha'], log['beta'])
716705 >>> print(sgd_dual_pi)
717706
0 commit comments