diff options
Diffstat (limited to 'ot')
-rw-r--r-- | ot/__init__.py | 2 | ||||
-rw-r--r-- | ot/gpu/__init__.py | 5 | ||||
-rw-r--r-- | ot/gpu/da.py | 69 |
3 files changed, 6 insertions, 70 deletions
diff --git a/ot/__init__.py b/ot/__init__.py index 1dde390..fa6600d 100644 --- a/ot/__init__.py +++ b/ot/__init__.py @@ -29,7 +29,7 @@ from .da import sinkhorn_lpl1_mm # utils functions from .utils import dist, unif, tic, toc, toq -__version__ = "0.4.0" +__version__ = "0.5.0b" __all__ = ["emd", "emd2", "sinkhorn", "sinkhorn2", "utils", 'datasets', 'bregman', 'lp', 'tic', 'toc', 'toq', 'gromov', diff --git a/ot/gpu/__init__.py b/ot/gpu/__init__.py index a2fdd3d..ed6dcc4 100644 --- a/ot/gpu/__init__.py +++ b/ot/gpu/__init__.py @@ -9,4 +9,9 @@ from .bregman import sinkhorn # # License: MIT License +import warnings + +warnings.warn("the ot.gpu module is deprecated because cudamat in no longer maintained", DeprecationWarning, + stacklevel=2) + __all__ = ["bregman", "da", "sinkhorn"] diff --git a/ot/gpu/da.py b/ot/gpu/da.py index 71a485a..85d43e6 100644 --- a/ot/gpu/da.py +++ b/ot/gpu/da.py @@ -13,7 +13,6 @@ Domain adaptation with optimal transport with GPU implementation import numpy as np from ..utils import unif -from ..da import OTDA from .bregman import sinkhorn import cudamat @@ -185,71 +184,3 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M_GPU, reg, eta=0.1, numItermax=10, W_GPU = W_GPU.transpose() return transp_GPU.asarray() - - -class OTDA_GPU(OTDA): - - def normalizeM(self, norm): - if norm == "median": - self.M_GPU.divide(float(np.median(self.M_GPU.asarray()))) - elif norm == "max": - self.M_GPU.divide(float(np.max(self.M_GPU.asarray()))) - elif norm == "log": - self.M_GPU.add(1) - cudamat.log(self.M_GPU) - elif norm == "loglog": - self.M_GPU.add(1) - cudamat.log(self.M_GPU) - self.M_GPU.add(1) - cudamat.log(self.M_GPU) - - -class OTDA_sinkhorn(OTDA_GPU): - - def fit(self, xs, xt, reg=1, ws=None, wt=None, norm=None, **kwargs): - cudamat.init() - xs = np.asarray(xs, dtype=np.float64) - xt = np.asarray(xt, dtype=np.float64) - - self.xs = xs - self.xt = xt - - if wt is None: - wt = unif(xt.shape[0]) - if ws is None: - ws = unif(xs.shape[0]) - - self.ws = ws - self.wt = wt - - self.M_GPU = pairwiseEuclideanGPU(xs, xt, returnAsGPU=True, - squared=True) - self.normalizeM(norm) - self.G = sinkhorn(ws, wt, self.M_GPU, reg, **kwargs) - self.computed = True - - -class OTDA_lpl1(OTDA_GPU): - - def fit(self, xs, ys, xt, reg=1, eta=1, ws=None, wt=None, norm=None, - **kwargs): - cudamat.init() - xs = np.asarray(xs, dtype=np.float64) - xt = np.asarray(xt, dtype=np.float64) - - self.xs = xs - self.xt = xt - - if wt is None: - wt = unif(xt.shape[0]) - if ws is None: - ws = unif(xs.shape[0]) - - self.ws = ws - self.wt = wt - - self.M_GPU = pairwiseEuclideanGPU(xs, xt, returnAsGPU=True, - squared=True) - self.normalizeM(norm) - self.G = sinkhorn_lpl1_mm(ws, ys, wt, self.M_GPU, reg, eta, **kwargs) - self.computed = True |