4 ms·
Maybe it's just me, but this looks like a bunch of incomprehensible gibberish code. I'm sure I could understand it if I spent many hours pouring over it, but wh
by eigenvalue 7y ago
Maybe it's just me, but this looks like a bunch of incomprehensible gibberish code. I'm sure I could understand it if I spent many hours pouring over it, but why would you ever do that? When written out in Python (or even in JS!), the whole thing is so much simpler looking and more closely resembles the underlying math. This is especially true if you use a package like Numpy. I know he said he didn't want to use any libraries, but if the underlying primitives in the problem are vectors/matrices, then it seems like you are reinventing the wheel in a very substandard way that doesn't aid in understanding in any way and results in something that isn't beautiful, isn't high performance, and is confusing for someone to read-- even if the person is familiar with the subject matter!
- kick 7y agobut if the underlying primitives in the problem are vectors/matrices, then it seems like you are reinventing the wheel in a very substandard way that doesn't aid in understanding in any way and results in something that isn't beautiful, isn't high performance, and is confusing for someone to read You mean like...both of the languages you listed? There's an obviously superior, faster, simpler language when working with vectors (APL), but people are obsessed with new languages. If you really think it can be done in Python better than in Haskell, why not demo it in Python? You'll get internet points, and if you're right, you'll have something to show for it.
- stfwn 7y ago> Why not demo it in Python? Not OP, but here: https://gist.github.com/stfwn/62e51d86ca4ff155becd3c6a14adf60e https://gist.github.com/stfwn/62e51d86ca4ff155becd3c6a14adf6... You should be able to wget the file and run it (Python 3) from start to finish without any set-up and get ~88% accuracy on the test set. It uses all the data (not one-sixth like in the blog posts) and does 200 iterations by default, so here's the loss plot on the training set if you want to skip all the fun: https://i.imgur.com/F57zmXV.png https://i.imgur.com/F57zmXV.png
- 80211 7y agoYou’re exactly right. But why use python in the Age of Rust?
- marmada 7y agoIf someone told me they wrote a neural net in Haskell, my first reaction would be "wow that's Cool!", after all I don't think I can do that. I wouldn't care if the code was gibberish.
- hopia 7y agoVery few comments or type signatures, as well as formatting and syntax highlighting is a little odd there, make it less readable.
- Jaxan 7y agoI agree that this would look more readable if they used a library for the vector math, instead of doing everything by hand.
- zackmorris 7y agoI've never found a functional programming language that's easy to read. The best way to understand functional programming without learning it is to learn an imperative language like Ruby that everyone says is easy but that is actually hard. Then it's: programming you know -> experience you don't have yet -> code everyone uses Ruby makes the jump to the last step without explaining the middle one. That's what the whole convention over configuration part is about. Functional programming languages do the exact same thing. All of those arrows and symbols and syntactic sugar transpile directly to Lisp. They're basically shorthand. Unfortunately, I've never seen tutorials talk about that translation. To get the middle part, it's probably best to start with the low-hanging fruit. Probably learn something like spreadsheets, then Scheme, then ClojureScript, then F#. I never made it as far as Haskell or Scala. I always get lost somewhere around monads and impurity. And all FP languages fall down at that point in similar ways anyway. You either treat mutable variables as imaginary numbers that aren't examined until they must be (lazily), or throw the rules out the window and let variables be reassigned or renamed to themselves with new values, which breaks the whole point of using FP in the first place. It's pretty much an open problem, and the failure to solve it satisfactorily is why no FP language has caught on yet in the mainstream IMHO.
- moomin 7y agoThis will probably shock you not at all, but I find this way easier to read than Python code. You can’t really compare with Numpy code since the author deliberately avoids loading libraries. Of course, I’m more familiar with Haskell. The fact you’re more familiar with imperative languages isn’t the argument for readability you think it is.