summaryrefslogtreecommitdiff
path: root/ot/gpu
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2018-09-24 11:09:48 +0200
committerRémi Flamary <remi.flamary@gmail.com>2018-09-24 11:09:48 +0200
commitca08b788af38a076f45f000003eb0e2f227d7fd5 (patch)
treee6dd45860861b15c5f6df2967ac4bfe5ceeae78b /ot/gpu
parentae1ede4ed31973213b5945721b7b9fe8e4992a1c (diff)
deprecate ot.gpu and remove OTDA classes from it
Diffstat (limited to 'ot/gpu')
-rw-r--r--ot/gpu/__init__.py5
-rw-r--r--ot/gpu/da.py69
2 files changed, 5 insertions, 69 deletions
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