diff options
author | Leo gautheron <gautheron@iv-cm-359.creatis.insa-lyon.fr> | 2017-04-24 10:43:44 +0200 |
---|---|---|
committer | Leo gautheron <gautheron@iv-cm-359.creatis.insa-lyon.fr> | 2017-04-24 10:43:44 +0200 |
commit | e2cf8538b05f026d73c6033777699af77e7508b5 (patch) | |
tree | 65e3537011f45cb4200aea2e9fdc5d68ffe1de90 /test/test_gpu_sinkhorn_lpl1.py | |
parent | 8fc74ed792cda0fc0073dab218f7fdc08bf3c1ba (diff) |
add GPU implementation sinkhorn lpl1
Diffstat (limited to 'test/test_gpu_sinkhorn_lpl1.py')
-rw-r--r-- | test/test_gpu_sinkhorn_lpl1.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_gpu_sinkhorn_lpl1.py b/test/test_gpu_sinkhorn_lpl1.py new file mode 100644 index 0000000..e6cdd31 --- /dev/null +++ b/test/test_gpu_sinkhorn_lpl1.py @@ -0,0 +1,28 @@ +import ot +import numpy as np +import time +import ot.gpu + + +def describeRes(r): + print("min:{:.3E}, max:{:.3E}, mean:{:.3E}, std:{:.3E}" + .format(np.min(r), np.max(r), np.mean(r), np.std(r))) + +for n in [5000, 10000, 15000, 20000]: + print(n) + a = np.random.rand(n // 4, 100) + labels_a = np.random.randint(10, size=(n // 4)) + b = np.random.rand(n, 100) + time1 = time.time() + transport = ot.da.OTDA_lpl1() + transport.fit(a, labels_a, b) + G1 = transport.G + time2 = time.time() + transport = ot.gpu.da.OTDA_lpl1() + transport.fit(a, labels_a, b) + G2 = transport.G + time3 = time.time() + print("Normal sinkhorn lpl1, time: {:6.2f} sec ".format(time2 - time1)) + describeRes(G1) + print(" GPU sinkhorn lpl1, time: {:6.2f} sec ".format(time3 - time2)) + describeRes(G2) |