Answers.Body: <p>Okay, I'm first going to review how NEAT works. I hope this helps you model NEAT successfully as a whole, not just limited to your question.</p>
  
  <p>We use neuro-evolution to create a specific behavior that solves a given task. The behavior can be simple and complex.</p>
  
  <p>Now let's focus on behavior... Different neural networks can create the same behavior (A.K.A the competing conventions problem). </p>
  
  <p>We also want to end up with a neural network that is very efficient. </p>
  
  <p>So we want to solve two problems with one algorithm (NEAT): find the behavior that solves a task and find the most efficient neural network that creates the behavior.</p>
  
  <p>There's a simple way to search for the most efficient neural net: start with the simplest neural net and slowly build the neural net up. </p>
  
  <p>The hard part is defining behavior (how do we define behavior in neural networks?). NEAT introduces their very interesting definition of behavior: an atomic unit of neural network behavior is the connection of the neural network: which node connects to which and with what weight.</p>
  
  <p>Now I'm approaching your question(concern): you want to make sure your genomes can grow complex, which means that you want to preserve the capacity for your genome to express complex behavior. As the paper states, behavior does not have anything to do with nodes, let alone node genes. Behavior is a set of neural network connections.</p>
  
  <p>So here's my answer to your question: care about crossing over connections, not for the node genes. Find an efficient way to calculate the node genes. For instance, you'll consume a lot of memory if you just concatenate node genes from two parents without overlaps. There is a chance that some of the node genes might not be in use (i.e. disabled connections, not inheriting some connection genes due to probability).</p>
  
  <p>Hope this helps :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-07T12:36:41.113Z
Answers.Text: Hi! Thank you for your answer. What do you mean by "an efficient way to calculate the node genes"? Do you mean I should do what our friend from AI_SE said (see my question) or do you mean something different by calculating the node genes?
Answers.UserDisplayName: Dara Kong
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-09T13:53:15.007Z
Answers.Text: I used the first method that the AI_SE friends said according to your question. What I did was that I would add the node genes during crossover. As every connection (gene) gets inherited, I added the node genes that the connection uses.
Answers.UserDisplayName: Younghoon Kim
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-09T15:12:51.430Z
Answers.Text: Thanks! That's what I thought. I was wondering if there was another solution. Your explanation helped me understand NEAT better.
Answers.UserDisplayName: Dara Kong
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-07T09:32:36.433Z
Answers.LastActivityDate: 2020-04-07T09:32:36.433Z
Answers.UserDisplayName: Younghoon Kim
Body: <p>I'm currently trying to code the NEAT algorithm by myself, but I got stuck with two questions. Here they are:</p>
  <p>What happens if during crossover a node is removed (or disabled) and there's a connection that was previously connected to that specific node? Because, in that case, some connections are no longer useful. Do I keep the useless connections or do I prevent this from happening? Or maybe I'm missing something?</p>
  <p>Someone on <a href="https://ai.stackexchange.com/a/13930/2444">AI SE</a> said that:</p>
  <blockquote>
  <p>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>
  </blockquote>
  <p>But the problem with that is that my genomes will lose some complexity. Maybe I can use the nodes during crossover, and then disable the connections that were using this node. That way, I'm keeping the genotype complex, but the phenotype is still working.</p>
  <p>Is there another way to workaround this problem or this is the best way?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-04T01:32:39.720Z
Comments.Text: Please, split this post into two. Ask the second question in its separate post. This helps the reader of your post to focus on one problem. See https://ai.stackexchange.com/help/on-topic for more details.
Comments.UserDisplayName: nbro
Tags: <neat><neuroevolution><crossover-operators><mutation-operators>
Title: Do I have to crossover my node genes in NEAT, and how?
UserDisplayName: Dara Kong
ThreadText: # Do I have to crossover my node genes in NEAT, and how?
  
  (Asked by: username_0 on 2020-04-03)
  
  I'm currently trying to code the NEAT algorithm by myself, but I got stuck with two questions. Here they are:
  
  What happens if during crossover a node is removed (or disabled) and there's a connection that was previously connected to that specific node? Because, in that case, some connections are no longer useful. Do I keep the useless connections or do I prevent this from happening? Or maybe I'm missing something?
  
  Someone on [AI SE](https://ai.stackexchange.com/a/13930/2444) said that:
  
  > 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
  
  But the problem with that is that my genomes will lose some complexity. Maybe I can use the nodes during crossover, and then disable the connections that were using this node. That way, I'm keeping the genotype complex, but the phenotype is still working.
  
  Is there another way to workaround this problem or this is the best way?
  
  **Tags:** neat, neuroevolution, crossover-operators, mutation-operators
  
  > **Comments:**
  > **username_1**: Please, split this post into two. Ask the second question in its separate post. This helps the reader of your post to focus on one problem. See https://ai.stackexchange.com/help/on-topic for more details.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-04-07. Score: 1 | Accepted answer
  
  Okay, I'm first going to review how NEAT works. I hope this helps you model NEAT successfully as a whole, not just limited to your question.
  
  We use neuro-evolution to create a specific behavior that solves a given task. The behavior can be simple and complex.
  
  Now let's focus on behavior... Different neural networks can create the same behavior (A.K.A the competing conventions problem).
  
  We also want to end up with a neural network that is very efficient.
  
  So we want to solve two problems with one algorithm (NEAT): find the behavior that solves a task and find the most efficient neural network that creates the behavior.
  
  There's a simple way to search for the most efficient neural net: start with the simplest neural net and slowly build the neural net up.
  
  The hard part is defining behavior (how do we define behavior in neural networks?). NEAT introduces their very interesting definition of behavior: an atomic unit of neural network behavior is the connection of the neural network: which node connects to which and with what weight.
  
  Now I'm approaching your question(concern): you want to make sure your genomes can grow complex, which means that you want to preserve the capacity for your genome to express complex behavior. As the paper states, behavior does not have anything to do with nodes, let alone node genes. Behavior is a set of neural network connections.
  
  So here's my answer to your question: care about crossing over connections, not for the node genes. Find an efficient way to calculate the node genes. For instance, you'll consume a lot of memory if you just concatenate node genes from two parents without overlaps. There is a chance that some of the node genes might not be in use (i.e. disabled connections, not inheriting some connection genes due to probability).
  
  Hope this helps :)
  
  > **Comments:**
  > **username_0**: Hi! Thank you for your answer. What do you mean by "an efficient way to calculate the node genes"? Do you mean I should do what our friend from AI_SE said (see my question) or do you mean something different by calculating the node genes?  
  > **username_2**: I used the first method that the AI_SE friends said according to your question. What I did was that I would add the node genes during crossover. As every connection (gene) gets inherited, I added the node genes that the connection uses.  
  > **username_0**: Thanks! That's what I thought. I was wondering if there was another solution. Your explanation helped me understand NEAT better.  
  
  ---
  
  