Answers.Body: <p>This is a summarized version of the explanation in <a href="https://www.cambridge.org/core/journals/knowledge-engineering-review/article/abs/neural-networks-a-comprehensive-foundation-by-simon-haykin-macmillan-1994-isbn-0023527817/EB35EC581662FFC75E3FCAD4DDB9FDD1" rel="nofollow noreferrer">Haykin 1994</a>, section 4.3.  (<a href="https://www.semanticscholar.org/paper/Learning-representations-by-back-propagating-errors-Rumelhart-Hinton/052b1d8ce63b07fec3de9dbb583772d860b7c769" rel="nofollow noreferrer">Rumelhart et al 1986</a> being the original reference, but Haykin breaks it down nicely for beginners.)</p>
  <p><span class="math-container">$\underbrace{\Delta w_{ji}(n)}_\textrm{weight correction} = \underbrace{\eta}_\textrm{learning rate }\cdot \underbrace{\delta_i(n)}_\textrm{ local gradient }\cdot \underbrace{y_i(n)}_\textrm{ input signal of neuron j }$</span></p>
  <p><span class="math-container">$\delta_j(n) = \psi^{'}_j\left(v_j\left(n\right)\right)\, e_j(n)$</span></p>
  <p><span class="math-container">$e_j(n) = d_j(n) - y_j(n)$</span> is the error for output neuron <span class="math-container">$j$</span></p>
  <p><span class="math-container">$e_j(n) = \sum\limits_k \delta_k(n)\, w_{kj}(n)$</span> is the error for hidden neuron <span class="math-container">$j$</span>.</p>
  <p><span class="math-container">$\psi$</span> is the activation function. <span class="math-container">$d$</span> is the correct value. <span class="math-container">$y$</span> is the predicted value. <span class="math-container">$w$</span> is the weight matrix.</p>
  <p>Note that what you're calling the error in the question is more commonly the &quot;weight correction&quot;. The error is just one part of that.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-09T14:06:08.610Z
Answers.Text: I havent taken a  Deep learning class at my university yet so my terms are layman terms.Thanks a lot btw!
Answers.UserDisplayName: Cerise
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-09T14:08:17.670Z
Answers.Text: Not a problem. I just wanted to avoid confusion since I've got an "error" term here that isn't what you meant by error.
Answers.UserDisplayName: Ray
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-09T14:00:18.133Z
Answers.LastActivityDate: 2023-10-09T14:00:18.133Z
Answers.UserDisplayName: Ray
Body: <p>I am building a neural network for a AI whose goal is to learn to implement the XOR logical function.I have this code so far:</p>
  <pre><code>class Node:
    prevNodes = []
    b = 0.5; 
  
  def __init__(self,value,nextNode):
      self.value = value
      self.nextNode = nextNode
      self.nextNode.value += self.value * b
      self.nextNode.prevNodes.append(self)
  
  def changeB(error):
      b +=error;
  
  def printVal(self):
      print(self.value+&quot;\n&quot;)
  
  
  class Network:
  
  def __init__(self,nodes):
      self.nodes = nodes
  
  def calcOutput(self):
      finalNode = self.nodes
      while self.nodes.nextNode is not None:
          finalNode = self.nodes.nextNode
      return 1-pow(e,-(finalNode.value))
  
  def digitize(val):
      if val&lt;0.5:
          val = 0
      else:
          val = 1
  
  def correctBiases():
  
  
  def checkAnswer():
  
      if input(&quot;is this answer correct?&quot;) is not digitize(calcOutput()):
  
          correctBiases()
  </code></pre>
  <p>Now I am writing the <code>correctBiases()</code> function. Which algorithm do I need to use to calculate the <code>error</code>?</p>
  
Tags: <neural-networks><ai-design>
Title: Which algorithm do I need to use to calculate the error?
UserDisplayName: Cerise
ThreadText: # Which algorithm do I need to use to calculate the error?
  
  (Asked by: username_0 on 2023-10-09)
  
  I am building a neural network for a AI whose goal is to learn to implement the XOR logical function.I have this code so far:
  
  ```
  class Node:
    prevNodes = []
    b = 0.5; 
  
  def __init__(self,value,nextNode):
      self.value = value
      self.nextNode = nextNode
      self.nextNode.value += self.value * b
      self.nextNode.prevNodes.append(self)
  
  def changeB(error):
      b +=error;
  
  def printVal(self):
      print(self.value+"\n")
  
  class Network:
  
  def __init__(self,nodes):
      self.nodes = nodes
  
  def calcOutput(self):
      finalNode = self.nodes
      while self.nodes.nextNode is not None:
          finalNode = self.nodes.nextNode
      return 1-pow(e,-(finalNode.value))
  
  def digitize(val):
      if val<0.5:
          val = 0
      else:
          val = 1
  
  def correctBiases():
  
  def checkAnswer():
  
      if input("is this answer correct?") is not digitize(calcOutput()):
  
          correctBiases()
  
  ```
  
  Now I am writing the `correctBiases()` function. Which algorithm do I need to use to calculate the `error`?
  
  **Tags:** neural-networks, ai-design
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-10-09. Score: 0 | Accepted answer
  
  This is a summarized version of the explanation in [Haykin 1994](https://www.cambridge.org/core/journals/knowledge-engineering-review/article/abs/neural-networks-a-comprehensive-foundation-by-simon-haykin-macmillan-1994-isbn-0023527817/EB35EC581662FFC75E3FCAD4DDB9FDD1), section 4.3. ([Rumelhart et al 1986](https://www.semanticscholar.org/paper/Learning-representations-by-back-propagating-errors-Rumelhart-Hinton/052b1d8ce63b07fec3de9dbb583772d860b7c769) being the original reference, but Haykin breaks it down nicely for beginners.)
  
  $\underbrace{\Delta w\_{ji}(n)}\_\textrm{weight correction} = \underbrace{\eta}\_\textrm{learning rate }\cdot \underbrace{\delta\_i(n)}\_\textrm{ local gradient }\cdot \underbrace{y\_i(n)}\_\textrm{ input signal of neuron j }$
  
  $\delta\_j(n) = \psi^{'}\_j\left(v\_j\left(n\right)\right)\, e\_j(n)$
  
  $e\_j(n) = d\_j(n) - y\_j(n)$ is the error for output neuron $j$
  
  $e\_j(n) = \sum\limits\_k \delta\_k(n)\, w\_{kj}(n)$ is the error for hidden neuron $j$.
  
  $\psi$ is the activation function. $d$ is the correct value. $y$ is the predicted value. $w$ is the weight matrix.
  
  Note that what you're calling the error in the question is more commonly the "weight correction". The error is just one part of that.
  
  > **Comments:**
  > **username_0**: I havent taken a  Deep learning class at my university yet so my terms are layman terms.Thanks a lot btw!  
  > **username_1**: Not a problem. I just wanted to avoid confusion since I've got an "error" term here that isn't what you meant by error.  
  
  ---
  
  