Skip to content

Using log parameter #44

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

Merged
merged 5 commits into from
Apr 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions ot/da.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,13 +1332,14 @@ class EMDTransport(BaseTransport):
on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1
"""

def __init__(self, metric="sqeuclidean", norm=None,
def __init__(self, metric="sqeuclidean", norm=None, log=False,
distribution_estimation=distribution_estimation_uniform,
out_of_sample_map='ferradans', limit_max=10,
max_iter=100000):

self.metric = metric
self.norm = norm
self.log = log
self.limit_max = limit_max
self.distribution_estimation = distribution_estimation
self.out_of_sample_map = out_of_sample_map
Expand Down Expand Up @@ -1371,11 +1372,16 @@ class label

super(EMDTransport, self).fit(Xs, ys, Xt, yt)

# coupling estimation
self.coupling_ = emd(
a=self.mu_s, b=self.mu_t, M=self.cost_, numItermax=self.max_iter
)
returned_ = emd(
a=self.mu_s, b=self.mu_t, M=self.cost_, numItermax=self.max_iter,
log=self.log)

# coupling estimation
if self.log:
self.coupling_, self.log_ = returned_
else:
self.coupling_ = returned_
self.log_ = dict()
return self


Expand Down Expand Up @@ -1432,7 +1438,7 @@ class SinkhornLpl1Transport(BaseTransport):
"""

def __init__(self, reg_e=1., reg_cl=0.1,
max_iter=10, max_inner_iter=200,
max_iter=10, max_inner_iter=200, log=False,
tol=10e-9, verbose=False,
metric="sqeuclidean", norm=None,
distribution_estimation=distribution_estimation_uniform,
Expand All @@ -1443,6 +1449,7 @@ def __init__(self, reg_e=1., reg_cl=0.1,
self.max_iter = max_iter
self.max_inner_iter = max_inner_iter
self.tol = tol
self.log = log
self.verbose = verbose
self.metric = metric
self.norm = norm
Expand Down Expand Up @@ -1480,12 +1487,18 @@ class label

super(SinkhornLpl1Transport, self).fit(Xs, ys, Xt, yt)

self.coupling_ = sinkhorn_lpl1_mm(
returned_ = sinkhorn_lpl1_mm(
a=self.mu_s, labels_a=ys, b=self.mu_t, M=self.cost_,
reg=self.reg_e, eta=self.reg_cl, numItermax=self.max_iter,
numInnerItermax=self.max_inner_iter, stopInnerThr=self.tol,
verbose=self.verbose)
verbose=self.verbose, log=self.log)

# deal with the value of log
if self.log:
self.coupling_, self.log_ = returned_
else:
self.coupling_ = returned_
self.log_ = dict()
return self


Expand Down