Unpopular (?) Opinion: Matrices are a great data structure. But, using linear algebra ops for the vectorization speedup alone is often an obfuscating optimization. A well-commented loop over the clearly-named elements is often better. (Plus, ya know -- numba).
-
-
-
Replying to @terrible_coder
Readability. You can look at a sequence of matrix operations and understand what it does, computationally, but outside common and familiar algorithms, the why and what part gets lost easily. What's this matrix represent? Where does the shape come from?
1 reply 0 retweets 1 like -
Replying to @generativist
Maybe I'm missing something, but I think that semantics shouldn't leak that far down into code. Keeping the implementation slower for the sake of readability removes so much of the benefit of computing.
1 reply 0 retweets 0 likes -
Replying to @terrible_coder @generativist
That's why we come up with abstractions: to shield nasty details for all but the brave.
1 reply 0 retweets 1 like -
Replying to @terrible_coder
I should have contextualized this better (see:
@kaznatcheev mentions, too.) If you're avoiding matrix ops in production code, you're probably doing the wrong thing. But, if you're using them in pedagogical code, you're probably not.2 replies 0 retweets 2 likes -
Replying to @generativist @kaznatcheev
I don't know, I still think it depends. In the case of Python, electing to use vanilla Python over np is pretty brutal in order of magnitude of difference in running times. I think if you develop in a principled manner and document, vector operations can be just as enlightening.
1 reply 0 retweets 2 likes -
Replying to @terrible_coder @kaznatcheev
Depends on the size (and if you have a reasonable numba expectation). That annotation amortizes it into oblivion, often.
1 reply 0 retweets 0 likes -
Then again: this whole thing was a hot take, so... ¯\_(ツ)_/¯
1 reply 0 retweets 1 like -
(Also a hypocritical one -- I'm not devectorizing my code, numba or not.)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.