Added a note about squared distances

This commit is contained in:
Jasper Snoek 2019-05-30 12:13:10 -04:00
parent 3d1e419e0d
commit 06d41fbad1

View File

@ -56,6 +56,9 @@ def main(unused_argv):
def softplus(x):
return np.logaddexp(x, 0.)
# Note, writing out the vectorized form of the identity
# ||x-y||^2 = <x-y,x-y> = ||x||^2 + ||y||^2 - 2<x,y>
# for computing squared distances would be more efficient (but less succinct).
def exp_quadratic(x1, x2):
return np.exp(-np.sum((x1 - x2)**2))