Answers.Body: <p>In your example, the output node would still get a value from <code>Input1</code>, even though <code>Input2</code> is disabled.</p>
  
  <p>If the child was:</p>
  
  <pre><code>Child = {
            (1, Input1, Output1),
            (2, Input2, Output2) //Disabled
           }
  </code></pre>
  
  <p>Then <code>Output2</code> would return 0, meaning it wasn't activated.</p>
  
  <p>For your second question, it is up to your implementation. You could:</p>
  
  <p>1.) Use only the connection genes in crossover, and derive your node genes from the connection genes</p>
  
  <p>2.) Test if every node is in use, and delete the ones that are not</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-28T18:06:23.497Z
Answers.Text: Your 2nd suggestion is in my opinion the most logical solution to this problem. Thank you!
Answers.UserDisplayName: SamuelMyself
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-13T03:58:42.020Z
Answers.LastActivityDate: 2019-08-13T03:58:42.020Z
Answers.UserDisplayName: Terry T.
Body: <p>I am implementing <a href="http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf" rel="nofollow noreferrer">NEAT</a> (neuroevolution of augmenting topologies) by Stanley. I am facing a problem during the crossover of genomes.</p>
  <p>Suppose two networks with connections</p>
  <pre><code>Genome1 = {    
      (1, Input1, Output), // numbers represent innovation numbers
      (2, Input2, Output)    
  } // more fit
  
  Genome2 = {    
      (1, Input1, Output),
      (2, Input2, Output), // disabled
      (3, Input2, Hidden1),
      (4, Hidden1, Output)    
  }
  </code></pre>
  <p>are crossed over, then the connection (Input2, Output) in the fitter parent has a chance of being disabled (<a href="http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf#page=12" rel="nofollow noreferrer">page 109, section 3.2, figure 4</a>),</p>
  <blockquote>
  <p>There's a preset chance that an inherited gene is disabled if it is disabled in either parent.</p>
  </blockquote>
  <p>and thus producing the following offspring:</p>
  <pre><code>Child = {
      (1, Input1, Output),
      (2, Input2, Output) //Disabled
  }
  </code></pre>
  <p>and thus render the network non-functional.</p>
  <p>Similarly, by this chance, nodes can get left in a state of uselessness after crossover (as having no outgoing connections or no connections at all).</p>
  <p>How can this be prevented or am I missing something here?</p>
  
Tags: <neural-networks><neat><neuroevolution>
Title: How can non-functional neural networks be avoided when the crossover produces a child with a disabled gene?
UserDisplayName: SamuelMyself
ThreadText: # How can non-functional neural networks be avoided when the crossover produces a child with a disabled gene?
  
  (Asked by: username_0 on 2019-07-07)
  
  I am implementing [NEAT](http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf) (neuroevolution of augmenting topologies) by Stanley. I am facing a problem during the crossover of genomes.
  
  Suppose two networks with connections
  
  ```
  Genome1 = {    
      (1, Input1, Output), // numbers represent innovation numbers
      (2, Input2, Output)    
  } // more fit
  
  Genome2 = {    
      (1, Input1, Output),
      (2, Input2, Output), // disabled
      (3, Input2, Hidden1),
      (4, Hidden1, Output)    
  }
  
  ```
  
  are crossed over, then the connection (Input2, Output) in the fitter parent has a chance of being disabled ([page 109, section 3.2, figure 4](http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf#page=12)),
  
  > There's a preset chance that an inherited gene is disabled if it is disabled in either parent.
  
  and thus producing the following offspring:
  
  ```
  Child = {
      (1, Input1, Output),
      (2, Input2, Output) //Disabled
  }
  
  ```
  
  and thus render the network non-functional.
  
  Similarly, by this chance, nodes can get left in a state of uselessness after crossover (as having no outgoing connections or no connections at all).
  
  How can this be prevented or am I missing something here?
  
  **Tags:** neural-networks, neat, neuroevolution
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-08-13. Score: 2 | Accepted answer
  
  In your example, the output node would still get a value from `Input1`, even though `Input2` is disabled.
  
  If the child was:
  
  ```
  Child = {
            (1, Input1, Output1),
            (2, Input2, Output2) //Disabled
           }
  
  ```
  
  Then `Output2` would return 0, meaning it wasn't activated.
  
  For your second question, it is up to your implementation. You could:
  
  1.) Use only the connection genes in crossover, and derive your node genes from the connection genes
  
  2.) Test if every node is in use, and delete the ones that are not
  
  > **Comments:**
  > **username_0**: Your 2nd suggestion is in my opinion the most logical solution to this problem. Thank you!  
  
  ---
  
  