예제 #1
0
n_samples = 1e4
n_features = 2
centers = 6
n_samples = np.int(n_samples)
data, gt = make_blobs(n_samples = n_samples, n_features = n_features, centers = centers)
data = data.astype(np.float32)
n_samples_sqrt = np.int(np.sqrt(n_samples))
n_clusters = [n_samples_sqrt / 2, n_samples_sqrt]
n_clusters = map(int,n_clusters)

generator = K_Means(cuda_mem="manual")

generator.n_clusters = 176
generator.max_iter = 1

generator.N = n_samples
generator.D = n_features

generator.centroids = generator._init_centroids(data)
generator.labels = cuda.pinned_array(shape=generator.N, dtype = np.int32)
generator._dists = cuda.pinned_array(shape=generator.N, dtype = np.float32)

generator._compute_cuda_dims(data)
gridDim = generator._gridDim
blockDim = generator._blockDim

print "grid: ", gridDim
print "block: ", blockDim

dData = cuda.to_device(data)