-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Hi,
i trj to edit the example.c to fit the source of my data like this:
==
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "kmcuda.h"
int main(int argc, const char** argv) {
assert(argc == 5);
float *Matrix, *centroids, average_distance;
int i, j, clusters_size;
uint32_t DimX, DimY, assignments;
FILE MatInput;
if (argv[1] != NULL) {
MatInput = fopen(argv[1], "r");
} else
exit(1);
if (argv[2] != NULL) {
DimX = atoi(argv[2]);
} else
exit(1);
if (argv[3] != NULL) {
DimY = atoi(argv[2]);
} else
exit(1);
if (argv[4] != NULL) {
clusters_size = atoi(argv[4]);
printf("%d\n\n", clusters_size);
} else
exit(1);
Matrix = calloc(DimX * DimY, sizeof(float));
// printf("%d %d %d", DimX, DimY, clusters_size);
for (i = 0; i < DimX * DimY; i++) {
fscanf(MatInput, " %*d %*d %f", &Matrix[i]);
}
fclose(MatInput);
for (i = 0; i < 10; i++) printf(" %f \n", Matrix[i]);
printf("\n");
// we will store cluster centers here
centroids = calloc(DimX * DimY, sizeof(float));
assert(centroids);
// we will store assignments of every sample here
assignments = calloc(DimX * DimY, sizeof(uint32_t));
assert(assignments);
KMCUDAResult result = kmeans_cuda(
kmcudaInitMethodPlusPlus,
NULL, // kmeans++ centroids initialization
0.01, // less than 1% of the samples are reassigned in the end
0.1, // activate Yinyang refinement with 0.1 threshold
kmcudaDistanceMetricL2, // Euclidean distance
DimX, DimY, clusters_size,
0xDEADBEEF, // random generator seed
0, // use all available CUDA devices
-1, // samples are supplied from host
0, // not in float16x2 mode
2, // moderate verbosity
Matrix, centroids, assignments, &average_distance);
free(Matrix);
free(centroids);
free(assignments);
assert(result == kmcudaSuccess);
printf(
"Average distance between a centroid and the corresponding "
"cluster members: %f\n",
average_distance);
return 0;
}
==
But at the end i get this error:
==
./example Mat_2.dat 1000 1000 2
2
0.000000
0.071224
0.110585
0.087457
0.082495
0.096096
0.109748
0.095193
0.101874
0.155612
arguments: 1 (nil) 0.010 0.10 0 1000 1000 2 3735928559 0 0 2 0x7fd68c22f010 0x7fd68be5e010 0x7fd68ba8d010 0x7ffc0c933d54
reassignments threshold: 10
yinyang groups: 0
example: Kmeans_Cuda.c:70: main: Assertion `result == kmcudaSuccess' failed.
Aborted (core dumped)
==
the input data is a symmetric matrix.
Anyone knows which could be the source of the error?
thanks a lot