Answers.Body: <p>To answer the main question:</p>
  <blockquote>
  <p>Can NEAT produce output which has no connection with any other node?</p>
  </blockquote>
  <p>Yes. This is a common property of most artificial neurons, and not really to do with NEAT.</p>
  <p>If you have a set of inputs to an artificial neuron <span class="math-container">$x_i$</span>, weighted by weights <span class="math-container">$w_i$</span>, and the output is <span class="math-container">$y$</span>, then one way to write the function for a single neuron is:</p>
  <p><span class="math-container">$$y = f(b + \sum_{\forall i}w_i x_i)$$</span></p>
  <p>where <span class="math-container">$f$</span> is the activation function (in your case you have said this is <span class="math-container">$\text{tanh}$</span>) and <span class="math-container">$b$</span> is the neuron's bias. The many other ways of writing this are usually to allow for looking at the larger structure of the network, and are equivalent when you consider just one neuron.</p>
  <p>Your disconnected neurons have an empty set of inputs, but that is not a problem for typical NN code used in NEAT. It means the NN's function in your case is <span class="math-container">$y = \text{tanh}(b)$</span>, which will be the same value no matter what the rest of the network does.</p>
  <p>As your action decision is an <span class="math-container">$\text{argmax}$</span> over all outputs, and the other outputs can vary, sometimes they will be lower than the fixed value, and in fact the neural network does not lose any major ability by having such a default for <em>one</em> of its outputs. NEAT networks do tend towards simplicity and can evolve to drop connections that are non-necessary.</p>
  <p>However, if two outputs were disconnected then one action would never be selected, which would result in poor performance in this problem (although you could potentially have all turns in the same direction for some tracks, or maybe no need to brake).</p>
  <blockquote>
  <p>Of course, the first thing I did why asking ChatGPT</p>
  </blockquote>
  <p>I recommend that you do not do this for anything important. ChatGPT when asked to explain technical things will output &quot;explainy&quot; text with some facts, some errors and a word salad of ideas that roughly link to your technical subject. Its answer to you that you quoted is basically nonsense with a few facts thrown in that are not explanatory for your question. Maybe a future version will be better at explaining technical subjects, but this version is not good for that use, and you will waste time trying to understand nonsense.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-06T21:52:16.793Z
Answers.Text: Thanks a lot for your answer. I better understand now. However, what do you mean by "costs that encourage the network to be sparsely connected". What could I do to achieve such a thing? Do you have an example?
Answers.UserDisplayName: Roux
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-06T22:04:31.390Z
Answers.Text: @Roux Actually this does not seem common in NEAT, but you can basically reduce fitness by some metric of the network such as number of nodes and links multiplied by a weight. I just checked now, and NEAT does not usually do this, but instead tends to achieve minimal structure by starting very simple and only cautiously adding new nodes - it is one of the design goals.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-06T19:52:43.537Z
Answers.LastActivityDate: 2023-03-07T07:52:42.240Z
Answers.LastEditDate: 2023-03-07T07:52:42.240Z
Answers.UserDisplayName: Neil Slater
Body: <p><a href="https://i.sstatic.net/H6wdQ.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/H6wdQ.gif" alt="img" /></a></p>
  <p>I recently developed a little tool called <a href="https://github.com/marcpinet/neat-cars" rel="nofollow noreferrer">Neat Cars</a> where you can drawa track, place a car and watch the NEAT algorithm in action (including the ANN).</p>
  <p>However, I saw something that caught my attention:</p>
  <p><a href="https://i.sstatic.net/EyMdq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EyMdq.png" alt="what" /></a></p>
  <p>Of course, the first thing I did why asking ChatGPT after seeing this as I don't think the drawing is lying. It gave me this exact explaination:</p>
  <blockquote>
  <p>In NEAT (NeuroEvolution of Augmenting Topologies), it is possible for an output node to have no connections with any other node in the neural network but still produce an output. This can happen when the output node is initially connected to an input node or when it is connected to a hidden node that later becomes disconnected from the network.</p>
  <p>When a neural network is evolving through NEAT, the algorithm may add or remove connections or nodes during the optimization process. If a connection between the output node and other nodes is removed, the output node can still produce an output because it may have learned to do so during previous generations or training iterations.</p>
  <p>Additionally, in NEAT, some output nodes may be designated as &quot;structural&quot; nodes, which means they are always included in the network regardless of their connectivity. These structural nodes can also produce outputs even if they are not connected to any other nodes.</p>
  <p>In summary, while it is not common in traditional neural network architectures for an output node to produce output without any input connections, it is possible in NEAT due to the way the algorithm evolves and optimizes neural networks.</p>
  </blockquote>
  <p>But still, I don't think it works that way. I'm still having doubts.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T17:00:16.387Z
Comments.Text: It isn't worth posting ChatGPT transcripts of answers to technical questions. ChatGPT output has no provenance, in that there's no way to trace where it got the text from, so whether it is effectively quoting, mis-quoting or just making stuff up, and you cannot trust that any sentence doesn't have some kind of error. So it's a bit like saying "I found this opinion on the internet", without links
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T17:05:09.547Z
Comments.Text: Second to that (1) What does the car with the disconnected Accelerate output do when you watch it? (2) What are the activation functions on the output neurons, and how does the agent interpret them? If you are using sigmoid activation, then a 0 input will produce 0.5 output which seems most likely to me, and likely means that the car will still accelerate.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T17:35:14.187Z
Comments.Text: @NeilSlater it actually does what he shows. I just make so if output.index(max(output)) == 0 then left, 1 = right, 2 = accelerate and 3 = brake. Also, what do you mean by 0.5? I'm using tanh function btw
Comments.UserDisplayName: Roux
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T18:43:34.967Z
Comments.Text: The winning car does not have that neural network, so is it one of the NNs that is passing by as the leader in one of the other frames? As you have posted a GIF, if is not really possible to pause or figure this out. It would help if you explained in more detail what it is that you are observing. Anyway, I expect the disconnected neuron will output based on the sum of its inputs (0) and its bias value. So it will have a fixed output. As the other outputs are connected and can vary, sometimes this fixed value will be the maximum one, so the car may still choose the accelerate action.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T18:46:13.870Z
Comments.Text: The output is showing the NN of the current lead car, which is why it becomes static  once there is only a single car.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T20:20:41.330Z
Comments.Text: @NeilSlater it does not become static, i'm asking why is there a node light on even if he is not linked with the system
Comments.UserDisplayName: Roux
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T20:25:29.567Z
Comments.Text: I dont know how the animation decides why the neuron lights up. But it could simply be for any positive value. That makes most sense from what I am seeing. By "static" I mean the NN structure is static. It is still showing the varying outputs, but it is not the same NN structure as the one you pulled out - it appears to be one NN only
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T21:49:38.013Z
Comments.Text: @NeilSlater as I said, it's only lighting up if its index (between 0 and 3 so) is the index of the max(outputs) gy the activate method. I think it's called argmax
Comments.UserDisplayName: Roux
Tags: <neural-networks><python><neat>
Title: Can NEAT produce output which has no connection with any other node?
UserDisplayName: Roux
ThreadText: # Can NEAT produce output which has no connection with any other node?
  
  (Asked by: username_0 on 2023-03-06)
  
  [![img](https://i.sstatic.net/H6wdQ.gif)](https://i.sstatic.net/H6wdQ.gif)
  
  I recently developed a little tool called [Neat Cars](https://github.com/marcpinet/neat-cars) where you can drawa track, place a car and watch the NEAT algorithm in action (including the ANN).
  
  However, I saw something that caught my attention:
  
  [![what](https://i.sstatic.net/EyMdq.png)](https://i.sstatic.net/EyMdq.png)
  
  Of course, the first thing I did why asking ChatGPT after seeing this as I don't think the drawing is lying. It gave me this exact explaination:
  
  > In NEAT (NeuroEvolution of Augmenting Topologies), it is possible for an output node to have no connections with any other node in the neural network but still produce an output. This can happen when the output node is initially connected to an input node or when it is connected to a hidden node that later becomes disconnected from the network.
  >
  > When a neural network is evolving through NEAT, the algorithm may add or remove connections or nodes during the optimization process. If a connection between the output node and other nodes is removed, the output node can still produce an output because it may have learned to do so during previous generations or training iterations.
  >
  > Additionally, in NEAT, some output nodes may be designated as "structural" nodes, which means they are always included in the network regardless of their connectivity. These structural nodes can also produce outputs even if they are not connected to any other nodes.
  >
  > In summary, while it is not common in traditional neural network architectures for an output node to produce output without any input connections, it is possible in NEAT due to the way the algorithm evolves and optimizes neural networks.
  
  But still, I don't think it works that way. I'm still having doubts.
  
  **Tags:** neural-networks, python, neat
  > **Comments:**
  > **username_1**: It isn't worth posting ChatGPT transcripts of answers to technical questions. ChatGPT output has no provenance, in that there's no way to trace where it got the text from, so whether it is effectively quoting, mis-quoting or just making stuff up, and you cannot trust that any sentence doesn't have some kind of error. So it's a bit like saying "I found this opinion on the internet", without links  
  > **username_1**: Second to that (1) What does the car with the disconnected Accelerate output do when you watch it? (2) What are the activation functions on the output neurons, and how does the agent interpret them? If you are using sigmoid activation, then a 0 input will produce 0.5 output which seems most likely to me, and likely means that the car will still accelerate.  
  > **username_0**: @NeilSlater it actually does what he shows. I just make so if output.index(max(output)) == 0 then left, 1 = right, 2 = accelerate and 3 = brake. Also, what do you mean by 0.5? I'm using tanh function btw  
  > **username_1**: The winning car does not have that neural network, so is it one of the NNs that is passing by as the leader in one of the other frames? As you have posted a GIF, if is not really possible to pause or figure this out. It would help if you explained in more detail what it is that you are observing. Anyway, I expect the disconnected neuron will output based on the sum of its inputs (0) and its bias value. So it will have a fixed output. As the other outputs are connected and can vary, sometimes this fixed value will be the maximum one, so the car may still choose the accelerate action.  
  > **username_1**: The output is showing the NN of the current lead car, which is why it becomes static  once there is only a single car.  
  > **username_0**: @NeilSlater it does not become static, i'm asking why is there a node light on even if he is not linked with the system  
  > **username_1**: I dont know how the animation decides why the neuron lights up. But it could simply be for any positive value. That makes most sense from what I am seeing. By "static" I mean the NN structure is static. It is still showing the varying outputs, but it is not the same NN structure as the one you pulled out - it appears to be one NN only  
  > **username_0**: @NeilSlater as I said, it's only lighting up if its index (between 0 and 3 so) is the index of the max(outputs) gy the activate method. I think it's called argmax  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-06. Score: 3 | Accepted answer
  
  To answer the main question:
  
  > Can NEAT produce output which has no connection with any other node?
  
  Yes. This is a common property of most artificial neurons, and not really to do with NEAT.
  
  If you have a set of inputs to an artificial neuron $x\_i$, weighted by weights $w\_i$, and the output is $y$, then one way to write the function for a single neuron is:
  
  $$y = f(b + \sum\_{\forall i}w\_i x\_i)$$
  
  where $f$ is the activation function (in your case you have said this is $\text{tanh}$) and $b$ is the neuron's bias. The many other ways of writing this are usually to allow for looking at the larger structure of the network, and are equivalent when you consider just one neuron.
  
  Your disconnected neurons have an empty set of inputs, but that is not a problem for typical NN code used in NEAT. It means the NN's function in your case is $y = \text{tanh}(b)$, which will be the same value no matter what the rest of the network does.
  
  As your action decision is an $\text{argmax}$ over all outputs, and the other outputs can vary, sometimes they will be lower than the fixed value, and in fact the neural network does not lose any major ability by having such a default for *one* of its outputs. NEAT networks do tend towards simplicity and can evolve to drop connections that are non-necessary.
  
  However, if two outputs were disconnected then one action would never be selected, which would result in poor performance in this problem (although you could potentially have all turns in the same direction for some tracks, or maybe no need to brake).
  
  > Of course, the first thing I did why asking ChatGPT
  
  I recommend that you do not do this for anything important. ChatGPT when asked to explain technical things will output "explainy" text with some facts, some errors and a word salad of ideas that roughly link to your technical subject. Its answer to you that you quoted is basically nonsense with a few facts thrown in that are not explanatory for your question. Maybe a future version will be better at explaining technical subjects, but this version is not good for that use, and you will waste time trying to understand nonsense.
  
  > **Comments:**
  > **username_0**: Thanks a lot for your answer. I better understand now. However, what do you mean by "costs that encourage the network to be sparsely connected". What could I do to achieve such a thing? Do you have an example?  
  > **username_1**: @Roux Actually this does not seem common in NEAT, but you can basically reduce fitness by some metric of the network such as number of nodes and links multiplied by a weight. I just checked now, and NEAT does not usually do this, but instead tends to achieve minimal structure by starting very simple and only cautiously adding new nodes - it is one of the design goals.  
  
  ---
  
  