summaryrefslogtreecommitdiff
path: root/ot/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'ot/gpu')
-rw-r--r--ot/gpu/__init__.py15
-rw-r--r--ot/gpu/da.py19
2 files changed, 27 insertions, 7 deletions
diff --git a/ot/gpu/__init__.py b/ot/gpu/__init__.py
index 0187a4f..213578c 100644
--- a/ot/gpu/__init__.py
+++ b/ot/gpu/__init__.py
@@ -13,11 +13,13 @@ In order to get the best erformances, we recommend to given only cupy
arrays to the functions and desactivate the conversion to numpy of the
result of the function with parameter ``to_numpy=False``.
-
-
-
"""
+# Author: Remi Flamary <remi.flamary@unice.fr>
+# Leo Gautheron <https://github.com/aje>
+#
+# License: MIT License
+
from . import bregman
from . import da
from .bregman import sinkhorn
@@ -27,10 +29,9 @@ from . import utils
from .utils import dist, to_gpu, to_np
-# Author: Remi Flamary <remi.flamary@unice.fr>
-# Leo Gautheron <https://github.com/aje>
-#
-# License: MIT License
+
+
__all__ = ["utils", "dist", "sinkhorn",
"sinkhorn_lpl1_mm", 'bregman', 'da', 'to_gpu', 'to_np']
+
diff --git a/ot/gpu/da.py b/ot/gpu/da.py
index 6aba29c..f5e7daa 100644
--- a/ot/gpu/da.py
+++ b/ot/gpu/da.py
@@ -10,10 +10,12 @@ Domain adaptation with optimal transport with GPU implementation
#
# License: MIT License
+
import cupy as np # np used for matrix computation
import cupy as cp # cp used for cupy specific operations
import numpy as npp
from . import utils
+
from .bregman import sinkhorn
@@ -131,6 +133,22 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
# separated
W = np.ones(M.shape)
for (i, c) in enumerate(classes):
+<<<<<<< HEAD
+ (_, nbRow) = indices_labels[i].shape
+ tmpC_GPU = cudamat.empty((Nfin, nbRow)).assign(0)
+ transp_GPU.transpose().select_columns(indices_labels[i], tmpC_GPU)
+ majs_GPU = tmpC_GPU.sum(axis=1).add(epsilon)
+ cudamat.pow(majs_GPU, (p - 1))
+ majs_GPU.mult(p)
+
+ tmpC_GPU.assign(0)
+ tmpC_GPU.add_col_vec(majs_GPU)
+ W_GPU.set_selected_columns(indices_labels[i], tmpC_GPU)
+
+ W_GPU = W_GPU.transpose()
+
+ return transp_GPU.asarray()
+=======
majs = np.sum(transp[indices_labels[i]], axis=0)
majs = p * ((majs + epsilon)**(p - 1))
W[indices_labels[i]] = majs
@@ -139,3 +157,4 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
return utils.to_np(transp)
else:
return transp
+>>>>>>> master