How to build your own neural network from scratch in Python
towardsdatascience.com
towardsdatascience.com
$ import a_whole_bunch_of_stuff
Good to see that this is not the case here :)
The fast.ai course has a similar exercise in the beginning, but you'll still import the weights from somewhere else.
Their fast.ai v1 library has a very short implementation too (loading the MINIST example dataset and then using Resnet18):
from fastai import *
from fastai.data import *
untar_data(MNIST_PATH)
data = image_data_from_folder(MNIST_PATH)
learn = ConvLearner(data, tvm.resnet18, metrics=accuracy)
learn.fit(1)
Done!Source: http://docs.fast.ai/
First, you get cake. Then you make it for 20 minutes. Then you have cake.
It has around 100k LOC.
OP is probably referring to somebody importing a high-level class that does something complex (auto-differentiation etc.)
I guess that there's always a software layer which may be considered "backbone". For people designing networks, all the tedious work of building the network is just plumbing, and they probably expect it to be automated from a formal description of the network.
The point is that you don't need any software layers at all to code up a basic neural network implementation. A programming language with basic floating-point operations is all you need. The algorithms are not complicated so even x86 Assembly is practical for this purpose if you're already experienced with it. So the "backbone" can simply be your favorite compiler.
> Do you want to code all the OS from the ground up
If it's a "make your OS" course then yes - a simple OS of course. If you want to become experienced in compilers, then writing a compiler from scratch for a simple language is mandatory for people who want to have solid fundamentals. It's not a coincidence that projects like these are common in Computer Science and Software Engineering courses.
I grafted my answer to the wrong post, I meant to respond to the guy talking about the project implicitely using Numpy.
Offtopic remark: It would be nice to be able to move a post to a different thread, or make a single answer to several messages.
Always surprises me that out of all the different kinds of internet communities, it's only the oft-maligned imageboards that consistently provide that feature.
I was kind of expecting Discourse to play with the idea, since they seem to be the modern-reboot-of-forums with the most traction + willingness to experiment, but they haven't so far, afaik.
The naïve solution would be to just limit nesting and order nested comments chronologically. Another solution may be to CC @postid in your messages and have posts display "responding to: id1, id4" at the top and "responses: id91" at the bottom with appropriate links. There's a question here about which post to write or display your response under. Finally, an extravagant solution would be to really represent discussion as a graph and I think a lot of time would need to be spent creating an interface with minimal frustration as I feel it can get really involved (i.e., a lot of clicking).
Curious what you or anyone else thinks.
I got a beer for anyone who can golf it under 5 lines
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
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
* 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?
If it’s just personal preference, I’m fine with that, I’m not trying to start a flame war.
Coming from the R side, I tend to prefer structures & functions as well, but if I tried to write Python that way I'd be wary about showing that code to anyone more entrenched in the Pythonic way of thinking.
But sure, it's a conventional thing. And for a long time the built-in alternatives to a class for such a datastructure tuples and dicts, neither which are very nice for functions to operate on (dict values have to be addressed with d['key'] instead of d.key). With a class and method there is also no doubt as to what the function operates on, which is convenient when there type hints and IDE support is missing. This is changing since Python 3.5 and type checking tools like MyPy.
Since Python 3.7 there are also data classes, a primitive for classes which just hold values. https://www.linuxjournal.com/content/introducing-python-37s-... But it will take a while before programming conventions change.
https://makeyourownneuralnetwork.blogspot.com/ https://www.amazon.com/dp/1530826608/ref=cm_sw_r_tw_dp_U_x_x...
First part goes into what a NN is and how backprop works, second part is an implementation in Python.
Strange reaction to a “beginner’s guide”, how can someone move on before they learn the basics?