diff options
author | Leo gautheron <gautheron@iv-cm-359.creatis.insa-lyon.fr> | 2017-04-20 12:12:15 +0200 |
---|---|---|
committer | Leo gautheron <gautheron@iv-cm-359.creatis.insa-lyon.fr> | 2017-04-20 12:12:15 +0200 |
commit | 16f51f971607efab2c73958d207c582b389406c8 (patch) | |
tree | 299a4f6f13faf8545d2144767e9a7791098aacf8 /ot/gpu/cudamat/test/test_learn.py | |
parent | 48ec27d8e1c2599bd6d9015d15f4204b8116af28 (diff) |
sinkhorn GPU implementation
Diffstat (limited to 'ot/gpu/cudamat/test/test_learn.py')
-rw-r--r-- | ot/gpu/cudamat/test/test_learn.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ot/gpu/cudamat/test/test_learn.py b/ot/gpu/cudamat/test/test_learn.py new file mode 100644 index 0000000..954757a --- /dev/null +++ b/ot/gpu/cudamat/test/test_learn.py @@ -0,0 +1,27 @@ +import pdb +import numpy as np +import nose +import cudamat as cm + +def setup(): + cm.cublas_init() + +def teardown(): + cm.cublas_shutdown() + +def test_mult_by_sigmoid_deriv(): + m = 256 + n = 128 + c_targets = np.array(np.random.randn(m, n)*10, dtype=np.float32, order='F') + c_acts = np.array(np.random.rand(m, n), dtype=np.float32, order='F') + + g_targets = cm.CUDAMatrix(c_targets) + g_acts = cm.CUDAMatrix(c_acts) + + c_targets = c_targets * c_acts * (1. - c_acts) + cm.learn.mult_by_sigmoid_deriv(g_targets, g_acts) + + assert np.max(np.abs(c_acts - g_acts.asarray())) < 10**-2, "Error in cudamat.learn.mult_by_sigmoid_deriv exceeded threshold" + +if __name__ == '__main__': + nose.runmodule() |