Hello all,
I am trying to run some test on both gpu and cpu to get the feeling about
their speed! I implemented regularized least square regression using both
cpu and gpu.In this algorithm one needs to calculate the inverse if kernel
matrix(k^-1) and then multiply it to corresponding target values achieve
the coefficient(c).C=(K^-1)*Y/ the problem comes up when I increase the
number of samples from 5000 to 6000. I don't know whether this is the
reasonable error because I'm using a lot of example or there is way to fix
this !
this is my code:
import numpy as np
from sklearn.datasets.samples_generator import make_regression
from numpy import linalg as LA
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
import scikits.cuda.linalg as la
la.init()
def cpu_compute(y,k):
c = np.dot(LA.inv(k), y)
print c
return
def gpu_compute(y,k):
y_gpu=gpuarray.to_gpu(y)
k_gpu=gpuarray.to_gpu(K)
k_inv=la.pinv(k_gpu)
c = la.dot(k_inv, y_gpu,transb='T')
print c
return
X, Y = make_regression(n_samples=6000, n_features=4, n_informative=1,
random_state=0, noise=35)
n=X.shape[1]
l=len(X)
K=np.dot(X, np.transpose(X))
K=K+np.identity(l)*n*7
########### doing statistics############3
import cProfile
import pstats
cProfile.run('cpu_compute(Y,K)','cpu_profile.txt')
p=pstats.Stats('cpu_profile.txt')
p.sort_stats('time').print_stats(10)
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cProfile.run('gpu_compute(Y,K)','gpu_profile.txt')
p=pstats.Stats('gpu_profile.txt')
p.sort_stats('time').print_stats(10)
Thanks in advance for any help
--
Mohsen
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda