|
13 | 13 |
|
14 | 14 | import numpy as np |
15 | 15 | from ..utils import unif |
16 | | -from ..da import OTDA |
17 | 16 | from .bregman import sinkhorn |
18 | 17 | import cudamat |
19 | 18 |
|
@@ -185,71 +184,3 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M_GPU, reg, eta=0.1, numItermax=10, |
185 | 184 | W_GPU = W_GPU.transpose() |
186 | 185 |
|
187 | 186 | 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