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 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?

  • $\begingroup$ 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 ai.stackexchange.com/help/on-topic for more details. $\endgroup$
    – nbro
    Commented Apr 4, 2020 at 1:32

1 Answer 1


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 :)

  • $\begingroup$ 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? $\endgroup$
    – Dara Kong
    Commented Apr 7, 2020 at 12:36
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Apr 9, 2020 at 13:53
  • 1
    $\begingroup$ Thanks! That's what I thought. I was wondering if there was another solution. Your explanation helped me understand NEAT better. $\endgroup$
    – Dara Kong
    Commented Apr 9, 2020 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .