diff options
author | Rémi Flamary <remi.flamary@gmail.com> | 2016-10-21 10:51:27 +0200 |
---|---|---|
committer | Rémi Flamary <remi.flamary@gmail.com> | 2016-10-21 10:51:27 +0200 |
commit | 581c6de782dca279edd97778cc474e7597788c0f (patch) | |
tree | 760161e1c7812d8caf77bf8acc543453c6213e39 /ot/utils.py | |
parent | 2109443f5bea396114d1f9e0563ba5c396378c57 (diff) |
demo+sinkhorn
Diffstat (limited to 'ot/utils.py')
-rw-r--r-- | ot/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ot/utils.py b/ot/utils.py new file mode 100644 index 0000000..1a1c6b8 --- /dev/null +++ b/ot/utils.py @@ -0,0 +1,15 @@ + +import numpy as np +from scipy.spatial.distance import cdist, pdist + + +def dist(x1,x2=None,metric='sqeuclidean'): + """Compute distance between samples in x1 and x2""" + if x2 is None: + return pdist(x1,metric=metric) + else: + return cdist(x1,x2,metric=metric) + +def dots(*args): + """ Stupid but nice dots function for multiple matrix multiply """ + return reduce(np.dot,args)
\ No newline at end of file |