forked from jgomezdans/gp_emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Performance
Sinan Shi edited this page May 13, 2015
·
9 revisions
| Call | Percentage (elapse time) | function |
|---|---|---|
| 1 | 4.8 | a = dist.cdist () |
| 1 | 8.6 | a = expX[self.D]np.exp(-0.5a) |
| 1 | 0.2 | mu = np.dot( a.T, self.invQt) |
| 1 | 5.2 | var=sum(dot()) |
| 10 | 19.6 | aa = self.inputs[:,d].flatten()[None,:] - testing[:,d].flatten()[:,None] |
| 10 | 58.5 | c = a*aa.T |
| 10 | 2.0 | deriv[:, d] = expX[d]*np.dot(c.T, self.invQt) |
| function | matrix size | computation costs |
|---|---|---|
| cdist | (N,10),(250,10) | N* 250* 10 |
| em | (N,250),(1) | N*250 |
| matmul(dot) | ||
| aa | (250),(N) | 250*N |
| c | (250,N)(250,N) | 250*N |
problem size = N, parameter numbers P = 10 , M=250
matrix size of 250 * N: aa, a
matrix size of 10 * N: testing, deriv
| N | single | double |
|---|---|---|
| 1e6 | 1.9G | 3.8G |
| 1e7 | 19.3G | 38.7G |
Timer unit: 1e-06 s
Total time: 7.39544 s
File: test.py
Function: predict at line 14
Line # Hits Time Per Hit % Time Line Contents
==============================================================
14 @profile
15 def predict ( self, testing, do_unc=True ):
16 1 4 4.0 0.0 ( nn, D ) = testing.shape
17 1 1 1.0 0.0 assert D == self.D
18
19 1 7 7.0 0.0 expX = np.exp ( self.theta )
20
21 1 367538 367538.0 5.0 a = dist.cdist ( np.sqrt(expX[:(self.D)])*self.inputs, np.sqrt(expX[:(self.D)])*testing, 'sqeuclidean')
22 1 621799 621799.0 8.4 a = expX[self.D]*np.exp(-0.5*a)
23 1 6 6.0 0.0 b = expX[self.D]
24
25 1 18835 18835.0 0.3 mu = np.dot( a.T, self.invQt)
26 1 2 2.0 0.0 if do_unc:
27 1 454542 454542.0 6.1 var = b - np.sum ( a * np.dot(self.invQ,a), axis=0)
28 # Derivative and partial derivatives of the function
29 1 518 518.0 0.0 deriv = np.zeros ( ( nn, self.D ) )
30
31 11 21 1.9 0.0 for d in xrange ( self.D ):
32 10 1418347 141834.7 19.2 aa = self.inputs[:,d].flatten()[None,:] - testing[:,d].flatten()[:,None]
33
34 10 4342587 434258.7 58.7 c = a*aa.T
35 10 163693 16369.3 2.2 deriv[:, d] = expX[d]*np.dot(c.T, self.invQt)
36 10 7535 753.5 0.1 print deriv[0:10,d]
37
38 1 1 1.0 0.0 if do_unc:
39 1 1 1.0 0.0 return mu, var, deriv
40 else:
41 return mu, deriv