News for hackers. Stuff that matters.
Re:How to build your own neural network from scratch in Python by vesche on Friday October 05, 2018 @01:16AM (#18145886)
Nah, let's make that 10 lines: https://gist.github.com/vesche/72dafed33d614710f03f1b75cff1c...

I got a beer for anyone who can golf it under 5 lines

Re:How to build your own neural network from scratch in Python by applecrazy on Friday October 05, 2018 @01:34AM (#18145944)
Naive solution (1 line):

https://gist.github.com/applecrazy/deda2fac6e83c07b93e001731...

Edit: I literally took newlines, converted to \n in a string, and then exec()ed the whole thing. Here's a repl of it working: https://repl.it/@applecrazy/Code-Golfing-a-Neural-Net

Re:How to build your own neural network from scratch in Python by vesche on Friday October 05, 2018 @02:36AM (#18146135)
Oh dear, I got played.

PM address if you want the beer, you sly dog. Obligatory, I'm a normal dude: http://vesche.github.io/

Edit: Wait, you can't PM on here... PM on reddit /u/vesche

Re:How to build your own neural network from scratch in Python by applecrazy on Friday October 05, 2018 @09:20AM (#18147850)
Well, I don't drink (see my bio), but thanks for the offer. :P
Re:How to build your own neural network from scratch in Python by rjplatte on Friday October 05, 2018 @12:32PM (#18149480)
I will accept the beer in his stead.
Re:How to build your own neural network from scratch in Python by earenndil on Friday October 05, 2018 @01:36AM (#18145948)
Sure! Optimizing for number of lines (instead of number of characters):

* Remove 'import numpy as n' and use __import__('numpy') in place of it everywhere

* Remove s and d functions; inline them where they're called

* Get rid of 'class N', as it's unnecessary. If adding globals is cheating, then you can do '__import__('math').x = x' instead of 'self.x = x' (yes this will work and persist).

* Technically, you don't have to print the result at the end

Where do I go for my beer?

Re:How to build your own neural network from scratch in Python by vesche on Friday October 05, 2018 @02:39AM (#18146152)
Re:How to build your own neural network from scratch in Python by anonytrary on Friday October 05, 2018 @01:19AM (#18145897)
Not readable, doesn't count ;)