[Python] Are there any neat ways to get warnings or errors if a numpy or scikit-learn...

Discussão em 'Python' iniciado por Stack, Setembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    This is something that seems to bite me repeatedly when using numpy for anything (most often things like scikit-learn).

    It's very easy to make an array non-contiguous (all it takes is a.T), then pass it to some scikit-learn operation. The operation may end up taking 5 minutes instead of 30 seconds, and, if you are lucky, you feel it's slower than it should be.

    For this reason, I would absolutely love to have an ability to detect matrix operations performed slowly on non-contiguous arrays. Probably a silenceable warning would be the ideal.

    Are there any reasonable approaches to this? One desperate idea that comes to my mind would be to hook BLAS functions and warn there, but I'm not even sure numpy does everything relevant using BLAS.

    Continue reading...

Compartilhe esta Página