Skip to content

Commit ca08b78

Browse files
committed
deprecate ot.gpu and remove OTDA classes from it
1 parent ae1ede4 commit ca08b78

File tree

2 files changed

+5
-69
lines changed

2 files changed

+5
-69
lines changed

ot/gpu/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
#
1010
# License: MIT License
1111

12+
import warnings
13+
14+
warnings.warn("the ot.gpu module is deprecated because cudamat in no longer maintained", DeprecationWarning,
15+
stacklevel=2)
16+
1217
__all__ = ["bregman", "da", "sinkhorn"]

ot/gpu/da.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import numpy as np
1515
from ..utils import unif
16-
from ..da import OTDA
1716
from .bregman import sinkhorn
1817
import cudamat
1918

@@ -185,71 +184,3 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M_GPU, reg, eta=0.1, numItermax=10,
185184
W_GPU = W_GPU.transpose()
186185

187186
return transp_GPU.asarray()
188-
189-
190-
class OTDA_GPU(OTDA):
191-
192-
def normalizeM(self, norm):
193-
if norm == "median":
194-
self.M_GPU.divide(float(np.median(self.M_GPU.asarray())))
195-
elif norm == "max":
196-
self.M_GPU.divide(float(np.max(self.M_GPU.asarray())))
197-
elif norm == "log":
198-
self.M_GPU.add(1)
199-
cudamat.log(self.M_GPU)
200-
elif norm == "loglog":
201-
self.M_GPU.add(1)
202-
cudamat.log(self.M_GPU)
203-
self.M_GPU.add(1)
204-
cudamat.log(self.M_GPU)
205-
206-
207-
class OTDA_sinkhorn(OTDA_GPU):
208-
209-
def fit(self, xs, xt, reg=1, ws=None, wt=None, norm=None, **kwargs):
210-
cudamat.init()
211-
xs = np.asarray(xs, dtype=np.float64)
212-
xt = np.asarray(xt, dtype=np.float64)
213-
214-
self.xs = xs
215-
self.xt = xt
216-
217-
if wt is None:
218-
wt = unif(xt.shape[0])
219-
if ws is None:
220-
ws = unif(xs.shape[0])
221-
222-
self.ws = ws
223-
self.wt = wt
224-
225-
self.M_GPU = pairwiseEuclideanGPU(xs, xt, returnAsGPU=True,
226-
squared=True)
227-
self.normalizeM(norm)
228-
self.G = sinkhorn(ws, wt, self.M_GPU, reg, **kwargs)
229-
self.computed = True
230-
231-
232-
class OTDA_lpl1(OTDA_GPU):
233-
234-
def fit(self, xs, ys, xt, reg=1, eta=1, ws=None, wt=None, norm=None,
235-
**kwargs):
236-
cudamat.init()
237-
xs = np.asarray(xs, dtype=np.float64)
238-
xt = np.asarray(xt, dtype=np.float64)
239-
240-
self.xs = xs
241-
self.xt = xt
242-
243-
if wt is None:
244-
wt = unif(xt.shape[0])
245-
if ws is None:
246-
ws = unif(xs.shape[0])
247-
248-
self.ws = ws
249-
self.wt = wt
250-
251-
self.M_GPU = pairwiseEuclideanGPU(xs, xt, returnAsGPU=True,
252-
squared=True)
253-
self.normalizeM(norm)
254-
self.G = sinkhorn_lpl1_mm(ws, ys, wt, self.M_GPU, reg, eta, **kwargs)
255-
self.computed = True

0 commit comments

Comments
 (0)