pynndescent icon indicating copy to clipboard operation
pynndescent copied to clipboard

NNDescent.update() fails even for compressed or uncompressed indexes

Open hobson opened this issue 3 years ago • 1 comments

$ conda install -c conda-forge pynndescent
$ ipython --version
8.0.1
$ python --version
Python 3.9.7
>>> import pynndescent as pynn
>>> pynn.__version__
'0.5.6'

I'm unable to update the index to append new vectors to the existing NN graph, whether or not the initial graph is compressed. vecs and vecs2 contain 300D GloVe Vectors:

>>> index = NNDescent(vecs, metric="cosine", compressed=False)
>>> index.update(vecs2)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [147], in <module>
----> 1 index.update(vecs2)

File ~/anaconda3/envs/nessvec/lib/python3.9/site-packages/pynndescent/pynndescent_.py:1614, in NNDescent.update(self, X)
   1609 rng_state = current_random_state.randint(INT32_MIN, INT32_MAX, 3).astype(
   1610     np.int64
   1611 )
   1612 X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C")
-> 1614 original_order = np.argsort(self._vertex_order)
   1616 if self._is_sparse:
   1617     self._raw_data = sparse_vstack([self._raw_data, X])

AttributeError: 'NNDescent' object has no attribute '_vertex_order'

hobson avatar Feb 18 '22 00:02 hobson

I believe you will have to call prepare() before update will work. That probably is not well documented. Sorry.

On Thu, Feb 17, 2022 at 7:30 PM Hobson Lane @.***> wrote:

$ conda install -c conda-forge pynndescent $ ipython --version 8.0.1 $ python --version Python 3.9.7

import pynndescent as pynn pynn.version '0.5.6'

I'm unable to update the index to append new vectors to the existing NN graph, whether or not the initial graph is compressed. vecs and vecs2 contain 300D GloVe Vectors:

index = NNDescent(vecs, metric="cosine", compressed=False)>>> index.update(vecs2)---------------------------------------------------------------------------AttributeError Traceback (most recent call last)Input In [147], in ----> 1 index.update(vecs2) File ~/anaconda3/envs/nessvec/lib/python3.9/site-packages/pynndescent/pynndescent_.py:1614, in NNDescent.update(self, X) 1609 rng_state = current_random_state.randint(INT32_MIN, INT32_MAX, 3).astype( 1610 np.int64 1611 ) 1612 X = check_array(X, dtype=np.float32, accept_sparse="csr", order="C")-> 1614 original_order = np.argsort(self._vertex_order) 1616 if self._is_sparse: 1617 self._raw_data = sparse_vstack([self._raw_data, X]) AttributeError: 'NNDescent' object has no attribute '_vertex_order'

— Reply to this email directly, view it on GitHub https://github.com/lmcinnes/pynndescent/issues/173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IUBMYPPYXYAH35ZHYGALU3WHLFANCNFSM5OWJKPCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

lmcinnes avatar Feb 18 '22 01:02 lmcinnes