1
$\begingroup$

I'm fairly new to ANNs. I know the general structure, the math, and the algorithms behind them. I figured the logical next step on my journey to fully understanding them would to be implement one myself from scratch, even if it's a fairly small one.

So I'm curious, coming from those who actually work with and deploy these things, are perceptrons/neurons typically implemented as objects with class variables, methods, etc. (kind of like nodes in a Linked List)? Or is there a more practical/memory-conservative way to build them?

$\endgroup$
3
  • 1
    $\begingroup$ In practice, you can find many existing open source software libraries implementing perceptrons or artificial neural networks $\endgroup$ – Basile Starynkevitch May 11 at 5:39
  • $\begingroup$ @BasileStarynkevitch Of course, but I was wondering (mostly for my own curiosity) how those libraries implement them. $\endgroup$ – lumpychum May 11 at 21:24
  • $\begingroup$ Since these libraries are opensource, you can download their source code and study it $\endgroup$ – Basile Starynkevitch May 12 at 5:02
0
$\begingroup$

Unless one performs an exhaustive search, it's difficult to answer your question.

However, in the widely used libraries, such as TensorFlow, PyTorch and sklearn, most abstractions (like neural networks and layers) are implemented as classes (see this, this and this examples, respectively), as the main programming language supported by these libraries is Python, which an object-oriented language (but note that Python also supports other programming paradigms, such as functional programming).

I don't know the statistics, but, from my experience, I would say that OOP (which tends to be intuitive to humans for obvious reasons) is the mostly widely used programming paradigm, as opposed to the (pure) functional paradigm.

However, in general, the programming paradigm used to implement a certain concept probably depends on the language that you want to use. For example, in Haskell, a purely functional programming language, you will probably implement a perceptron as a sequence of functions (see this example). Another example is NumPy, which, although the primary interface is written in Python, under the hood, is primarily implemented in C, a non-OOP language (see e.g. this example, where you see many functions, but no class).

This should also partially answer your other question. In some cases, you will implement a concept using the programming language and paradigm that improves the efficiency of your implementation (e.g. the case of NumPy).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.