4 ms·
agree with you, apl is great for ML, see this 6 lines Neural Network Example by apl with no deps: https://github.com/ghosthamlet/ann.apl https://github.com/gho
by ghosthamlet 10y ago
agree with you, apl is great for ML, see this 6 lines Neural Network Example by apl with no deps: https://github.com/ghosthamlet/ann.apl https://github.com/ghosthamlet/ann.apl
all code here:
l0 ← 4 3 ⍴ 0 0 1 0 1 1 1 0 1 1 1 1
y ← 4 1 ⍴ 0 0 1 1
syn0 ← 3 1 ⍴ 0.5069797399 0.5703818579 0.9265880619
i ← 0
e ← 2.718281828459045
:While i < 10000 ⋄ i ← i + 1 ⋄ d ← l0 +.× syn0 ⋄ l1 ← 1 ÷ 1 + e * 0 - d ⋄ l1_err ← y - l1 ⋄ l1_delta ← l1_err × l1 × 1 - l1 ⋄ syn0 ← syn0 + (⍉ l0) +.× l1_delta ⋄ :EndWhile
l1
- ghosthamlet 10y agoby the way, it is a ports from 11 lines python version here: http://iamtrask.github.io/2015/07/12/basic-python-network/ http://iamtrask.github.io/2015/07/12/basic-python-network/, isn't it more readable concise and beautiful than python version? if our all ML codes use apl, it will be a cool world.
- cwyers 10y ago> isn't it more readable concise and beautiful than python version? No.
- minimaxir 10y agoTo add to this, the which-loop-in-one-line-of-code is not self-documenting, which is important for data/ML in particular when others need to verify your code.
- cwyers 10y agoAnd it's not any shorter in terms of statements, they're just using the diamond operator to put all the statements in the loop on one line.
- klibertp 10y agoIt could simply be a badly written bit of APL. Although I don't know APL, I have some experience with J and I think the `:while` construct used here suggest more or less literal translation of the Python code.
- Sean1708 10y agoIs it possible to put that while loop on multiple lines? It looks like there are 6 different assignments in there, and trying to pick out what is happening is very hard when it's all on one line like that.
- Avshalom 10y agoYou can break it up at each diamond but then you'd need to wrap it in a function which would be harder to cut and paste into a repl
- rebootthesystem 10y agoHmmmm. This is a bad example of APL. Source: I used APL professionally for over ten years. For one thing, real APL does not have constructs like "while". That's the whole point of the language, to remove the need for the programmer to have to think this way. Also, this isn't, strictly speaking, six lines of code. The diamond is a statement separator. This is more like 15 or 20 lines (didn't count). Not that this is an important metric at all.
- sevensor 10y agoI'd be interested to know: for what kind of application did you use APL?
- rebootthesystem 10y agoQuite a range, actually. From business applications to robotics and DNA sequencing.