Skip to content

Use pseudo-inverse computation#8

Merged
chuckwondo merged 1 commit intodevelopfrom
issue7-singular-matrix
Apr 22, 2024
Merged

Use pseudo-inverse computation#8
chuckwondo merged 1 commit intodevelopfrom
issue7-singular-matrix

Conversation

@chuckwondo
Copy link
Contributor

Use numpy.linalg.pinv instead of numpy.linalg.inv to avoid "singular matrix" errors.

Upgrade numpy in Dockerfile to avoid "hanging" during computation of pseudo-inverse.

Fixes #7

Use `numpy.linalg.pinv` instead of `numpy.linalg.inv` to avoid
"singular matrix" errors.

Upgrade `numpy` in `Dockerfile` to avoid "hanging" during computation of
pseudo-inverse.

Fixes #7
@chuckwondo chuckwondo requested review from arthurduf and nemo794 April 18, 2024 14:44
@chuckwondo
Copy link
Contributor Author

@arthurduf, please take a look at this. I suggest pulling the branch and testing.

@arthurduf
Copy link
Collaborator

All good for me

@chuckwondo chuckwondo merged commit 0d29431 into develop Apr 22, 2024
@nemo794
Copy link
Collaborator

nemo794 commented Apr 23, 2024

Just a heads up that numpy.linalg.pinv takes a significantly longer to run than numpy.linalg.inv. (That said, I confirmed via htop that pinv does use all available cores, so we're good there.)

Is this what we want?

>>> import timeit
>>> inv = '''\
... import numpy as np
... pos = np.random.randint(0, 10, size=(5000,5000))
... np.linalg.inv(pos)
... '''
>>> pinv = '''\
... import numpy as np
... pos = np.random.randint(0, 10, size=(5000,5000))
... np.linalg.pinv(pos)
... '''
>>> timeit.timeit(inv, number=1)
4.161739458999364
>>> timeit.timeit(pinv, number=1)
43.71366904099705

@chuckwondo
Copy link
Contributor Author

Just a heads up that numpy.linalg.pinv takes a significantly longer to run than numpy.linalg.inv. (That said, I confirmed via htop that pinv does use all available cores, so we're good there.)

Is this what we want?

>>> import timeit
>>> inv = '''\
... import numpy as np
... pos = np.random.randint(0, 10, size=(5000,5000))
... np.linalg.inv(pos)
... '''
>>> pinv = '''\
... import numpy as np
... pos = np.random.randint(0, 10, size=(5000,5000))
... np.linalg.pinv(pos)
... '''
>>> timeit.timeit(inv, number=1)
4.161739458999364
>>> timeit.timeit(pinv, number=1)
43.71366904099705

Generally speaking, as long as this has the intended effect of consuming resources, I'd say this is fine. The actual computation is not what we care about, is it? Unless this particular calculation is going to cause the larger bboxes to take inordinately long (hours?) to complete, this should be fine, no?

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

Successfully merging this pull request may close these issues.

Some bbox inputs raise numpy.linalg.LinAlgError: Singular matrix

3 participants