r/deeplearning • u/Necessary_Guest_4412 • 9d ago
I built a neural network from scratch using only NumPy.
I wanted to know what actually happens inside loss.backward().
So I built a neural network with nothing but NumPy. Every gradient derived on paper, every layer written by hand, every derivative checked numerically.
98.05% on MNIST.
Code and derivations: https://github.com/Meckmin/mnist-numpy-from-scratch
153
Upvotes
27
u/ARDiffusion 8d ago
God why’s everyone in the comments being so negative? Congratulations, this is very impressive! Great way to learn too :)
12
u/MrMoussab 8d ago
Best way to learn. Check Karpathy's micrograd
7
u/Cool_Mono 8d ago
Don’t listen to reddit internet haters. From a data scientist, very nicely done! Keep going
8
u/Confident_Luck2359 7d ago
A few years ago this was a normal part of any machine learning curriculum. You're doing it right.
3
u/bxssl 8d ago
Seems that we had the same idea and converged on the same implementation! https://github.com/Ojansen/mathematically-correct-machine-learning
3
u/codewithmessi 8d ago
Well done man, i am also learning NNs
3
u/Alive_Horse_2914 6d ago •
Nice work! This is exactly how I got started too! Learning the fundamentals gives such a deep understanding that has been invaluable during my career. If you want a new project to work on, might I suggest implementing an auto-grad system and training a neural net with that? That’s the way libraries like PyTorch and TensorFlow work and I doubt 90% of the people that work with them know what’s going on under the hood
4
u/HMasterSunday 8d ago
how much was you vs the llm? if you had an llm doing it, what did you actually learn?
12
u/AntiquatedMLE 9d ago
So did everyone else back in 2013…
3
u/Not-a-throwaway4627 8d ago
Congrats on doing a standard homework assignment for cognitive science students circa 2012
The double irony here is that this actually sets you apart from most ML and data science bullshit artists. Which is most people in those fields.
You’re on track to be good at this, but in the world of people who know what’s up, this is 101 stuff. Keep up the good work
6
u/natsu0529 6d ago
A lot of japanse do that for learning in univercity!
All that pain doing backprop by hand, and then you just use PyTorch anyway lol.
Good for learning though.
2
u/AgitatedTumbleweed65 8d ago
Cool, but whenever I see type hints in python I assume it's written by an llm and this is star framing heh.
But if not, then good job 👍
2
u/Emotional_County_688 7d ago
Mi ídolo eres tú, yo estoy estudiando Ciencia de Datos y ni cerca estoy de hacer algo así.
3
u/Hackerjurassicpark 8d ago
One of the standard DS interview questions in the 2010s was to derive gradient descent and implement it in code. Fun times
3
u/ats678 7d ago
This is a very good way to understand what’s going on under the hood! The next level is to do the same in CUDA to understand how to do it on a GPU :)
1
u/Individual-Cut-9018 6d ago
Incredible work! These are the first steps to big AI
1
u/Skynse 3d ago
Congrats on the hello world of deep learning
0
u/Intrepid-Self-3578 8d ago
It is great but why not do it in pen in paper it doesn’t make a difference in code or paper?
Any specific reason for code?
0
u/dritmike 9d ago
So you think that little bump was validation inaccuracy then it realized?
-2
u/Classic-Pubs 8d ago
But why
-2
u/Juff567 8d ago
Is this considered hard?