9 ms·
Ultra simplified "MNIST" in 60 lines of Python with NumPy
- etienne89 2y agoThat reminds me of the article „a neural network in 11 lines of code“ from 2015 (although not on MNIST, rather some kind of XOR) https://iamtrask.github.io/2015/07/12/basic-python-network/ https://iamtrask.github.io/2015/07/12/basic-python-network/
- tonio 2y agoBeautiful! Same in spirit as what I was going for, but even better. I really like the way the weights are updated in this one. Thanks for showing me this!
- mankyd 2y agoThe description: "no dependencies." The first line: "import numpy as np"
- deleted 2y ago[deleted]
- tonio 2y agoyou got me, lol. to be fair the only reason numpy is there is because truly pure python doesn't have matmuls, and I didn't think reimplementing it wouldn't serve a didactic purpose. A cool idea for a v2 without numpy would be implementing matmuls with lists, matrix transpose with zip() and switching np.exp for math.exp. And getting all that on fewer lines as possible.
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- hi 2y agoTinygrad offers a superior MNIST implementation with minimal dependencies[0]. [0] https://github.com/tinygrad/tinygrad/blob/master/docs/mnist.md https://github.com/tinygrad/tinygrad/blob/master/docs/mnist....
- juliangoldsmith 2y agoAutograd hides the backward pass in that implementation, but this code spells it out explicitly.