Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what about the ValueError: bad alignment #12

Open
yang502 opened this issue Jul 28, 2017 · 5 comments
Open

what about the ValueError: bad alignment #12

yang502 opened this issue Jul 28, 2017 · 5 comments

Comments

@yang502
Copy link

yang502 commented Jul 28, 2017

My input dataset has converted as numpy matrices by np.asmatrix() and it's dim is 1024;
I use the python API

@zekizz
Copy link

zekizz commented Dec 7, 2017

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?

@aaalgo
Copy link
Owner

aaalgo commented Dec 7, 2017

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).

@cestas
Copy link

cestas commented Mar 22, 2018

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.

@cestas
Copy link

cestas commented Mar 22, 2018

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....

@aaalgo
Copy link
Owner

aaalgo commented Mar 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants