4 ms·
forcing pretty much all computation no matter how trivial into contortions via numpy incantations so that the inner loops can run in native extensions Th
by jpfr 9y ago
forcing pretty much all computation no matter how trivial
into contortions via numpy incantations so that the inner
loops can run in native extensions
That's actually a big plus in my book.
Welcome to the development of Matlab-style code. It can be pretty disheartening to see a complicated hand-crafted algorithm replaced by, say, a matrix multiplication. Try to find Matlab/numpy implementations from paper authors. This programming style is a bit difficult to get used to initially. But it will become incredibly powerful as you start thinking in algebraic operations.
Also, don't do debug runs on the full data. Implement ideas with a subset that computes fast. Then simplify the code and make it fast. Then run it on the full dataset.
If you absolutely need to combine linear algebra operations with fast imperative code, have a go at the Julia language [1] or use a C++ library like Eigen [2] or Armadillo [3].
[1] https://julialang.org/ https://julialang.org/
[2] http://eigen.tuxfamily.org/index.php?title=Main_Page http://eigen.tuxfamily.org/index.php?title=Main_Page
[3] http://arma.sourceforge.net/ http://arma.sourceforge.net/