kgraph
kgraph copied to clipboard
what about the ValueError: bad alignment
My input dataset has converted as numpy matrices by np.asmatrix() and it's dim is 1024; I use the python API
I have the same problem. This may be related to the shape of input matrix: the number of samples should be larger than the dimension of features to some extent. How to handle this problem?
I need more details. A well-aligned piece of data should start with an address divisible by 4 or 8, and the size of each row should be divisible by 4 or 8 (4 for float and 8 for double).
Hi, I'm running into a similar "valueError: bad alignment". I have a numpy array shape (100000,24) of dtype float32 but I get the 'bad alignment error'. I'm not sure what you mean by 'the data should start with an address divisible by 4 or 8'. How do I ensure my numpy-array has this kind of address? the numpy array is made from a subset of columns from a pandas dataframe. If i make a numpy array from random.rand(100000,24), then i dont get the valueError and the KNN graph is constructed.
I found a 'hacky' way of solving this. just repopulating the random.rand matrix with the values from the dataframe matrix... i suppose the data is now at the correct memory address....
The easiest way is to np.copy the matrix before feeding it in. Sometimes the matrix is a view of a bigger matrix. In such case, both the view and the original matrix share the underlying data and therefore the same row stride.