Answers.Body: <p>Unless one performs an exhaustive search, it's difficult to answer your question.</p>
  <p>However, in the widely used libraries, such as TensorFlow, PyTorch and sklearn, most abstractions (like neural networks and layers) are implemented as classes (see <a href="https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/keras/layers/recurrent_v2.py#L964-L1291" rel="nofollow noreferrer">this</a>, <a href="https://pytorch.org/docs/stable/_modules/torch/nn/modules/rnn.html#LSTM" rel="nofollow noreferrer">this</a> and <a href="https://github.com/scikit-learn/scikit-learn/blob/15a949460/sklearn/linear_model/_perceptron.py#L8" rel="nofollow noreferrer">this</a> examples, respectively), as the main programming language supported by these libraries is <a href="https://en.wikipedia.org/wiki/Python_(programming_language)" rel="nofollow noreferrer">Python</a>, which an object-oriented language (but note that Python also supports other programming paradigms, such as functional programming).</p>
  <p>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.</p>
  <p>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 <a href="https://hackage.haskell.org/package/perceptron-0.1.0.3/src/src/Learning/Perceptron.hs" rel="nofollow noreferrer">this</a> 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. <a href="https://github.com/numpy/numpy/blob/main/numpy/random/src/distributions/distributions.c" rel="nofollow noreferrer">this</a> example, where you see many functions, but no class).</p>
  <p>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).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-13T11:29:03.523Z
Answers.LastActivityDate: 2021-05-13T11:34:32.707Z
Answers.LastEditDate: 2021-05-13T11:34:32.707Z
Answers.UserDisplayName: nbro
Body: <p>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.</p>
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-11T05:39:27.223Z
Comments.Text: In practice, you can find many existing open source software libraries implementing perceptrons or artificial neural networks
Comments.UserDisplayName: Basile Starynkevitch
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-11T21:24:33.987Z
Comments.Text: @BasileStarynkevitch Of course, but I was wondering (mostly for my own curiosity) how those libraries implement them.
Comments.UserDisplayName: lumpychum
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-12T05:02:27.773Z
Comments.Text: Since these libraries are opensource, you can download their source code and study it
Comments.UserDisplayName: Basile Starynkevitch
Tags: <neural-networks><implementation><artificial-neuron><perceptron>
Title: In practice, are perceptrons typically implemented as objects?
UserDisplayName: lumpychum
ThreadText: # In practice, are perceptrons typically implemented as objects?
  
  (Asked by: username_0 on 2021-05-10)
  
  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?
  
  **Tags:** neural-networks, implementation, artificial-neuron, perceptron
  
  > **Comments:**
  > **username_1**: In practice, you can find many existing open source software libraries implementing perceptrons or artificial neural networks  
  > **username_0**: @username_1 Of course, but I was wondering (mostly for my own curiosity) how those libraries implement them.  
  > **username_1**: Since these libraries are opensource, you can download their source code and study it  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-05-13. Score: 1 | Accepted answer
  
  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](https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/keras/layers/recurrent_v2.py#L964-L1291), [this](https://pytorch.org/docs/stable/_modules/torch/nn/modules/rnn.html#LSTM) and [this](https://github.com/scikit-learn/scikit-learn/blob/15a949460/sklearn/linear_model/_perceptron.py#L8) examples, respectively), as the main programming language supported by these libraries is [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), 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](https://hackage.haskell.org/package/perceptron-0.1.0.3/src/src/Learning/Perceptron.hs) 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](https://github.com/numpy/numpy/blob/main/numpy/random/src/distributions/distributions.c) 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).
  
  
  ---
  
  