for loop speedup in grdients X

This commit is contained in:
James Hensman 2014-09-16 13:20:38 +01:00
parent ed754823be
commit ff63617286

View file

@ -171,7 +171,8 @@ class Stationary(Kern):
#the lower memory way with a loop
ret = np.empty(X.shape, dtype=np.float64)
[np.sum(tmp*(X[:,q][:,None]-X2[:,q][None,:]), axis=1, out=ret[:,q]) for q in xrange(self.input_dim)]
for q in xrange(self.input_dim):
np.sum(tmp*(X[:,q][:,None]-X2[:,q][None,:]), axis=1, out=ret[:,q])
ret /= self.lengthscale**2
return ret