From 581c6de782dca279edd97778cc474e7597788c0f Mon Sep 17 00:00:00 2001 From: RĂ©mi Flamary Date: Fri, 21 Oct 2016 10:51:27 +0200 Subject: demo+sinkhorn --- ot/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ot/utils.py (limited to 'ot/utils.py') 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 -- cgit v1.2.3