Answers.Body: <p>Using evolutionary algorithms to evolve neural networks is called <a href="http://www.scholarpedia.org/article/Neuroevolution" rel="nofollow">neuroevolution</a>. </p>
  
  <p>Some neuroevolution algorithms optimize only the <em>weights</em> of a neural network with fixed topology. That sounds not like what you want. Other neuroevolution algorithms optimize both the <em>weights</em> and <em>topology</em> of a neural net. These kinds of algorithms seem more appropriate for your aims, and are sometimes called TWEANNs (Topology and Weight Evolving Neural Networks).</p>
  
  <p>One popular algorithm is called <a href="https://www.cs.ucf.edu/~kstanley/neat.html" rel="nofollow">NEAT</a>, and is probably a good place to start, if only because there are a multitude of implementations, one of which hopefully is written in your favorite language. That would at least give you a baseline to work with. </p>
  
  <p>NEAT encodes a neural network genome directly as a graph structure. Mutations can operate on the structure of the network by adding new links (by connecting two nodes not previously connected) or new nodes (by splitting an existing connection), or can operate only on changing the weights associated with edges in the graphs (called mutating the weights). 
  To give you an idea of the order of magnitude of the sizes of ANNs this particular algorithm works with, it would likely struggle with more than 100 or 200 nodes. </p>
  
  <p>There are more scalable TWEANNs, but they're more complex and make assumptions about the kinds of structures they generate that may not always be productive in practice. For example, another way to encode the structure of a neural network, is as the product of a seed pattern that is repeatedly expanded by a grammar (e.g. an L-system). You can much more easily explore larger structures, but because they're generated by a grammar they'll have a characteristic self-repeating sort of feel. HyperNEAT is a popular extension of NEAT that makes a different sort of assumption (that patterns of weights can be easily expressed as a function of geometry), and can scale to ANNs with millions of connections when that assumption well-fits a particular domain.</p>
  
  <p>There are a few survey papers linked in the top link if you want to observe a greater variety of techniques.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-06T06:25:05.383Z
Answers.LastActivityDate: 2016-09-06T06:25:05.383Z
Answers.UserDisplayName: Joel Lehman
Answers.Body: <p>Section 4.2 of <a href="https://cs.gmu.edu/~sean/book/metaheuristics/">"Essentials of Metaheuristics"</a> has a wealth of information on alternative ways of encoding graph structures via Genetic Algorithms.</p>
  
  <p>With particular regard to evolving ANNs, I would personally not be inclined to implement this sort of thing 'from scratch':</p>
  
  <p>The field of neuroevolution has been around for some time, and the implementation some of the methods, such as Neuroevolution of Augmenting Topologies (<a href="http://www.cs.ucf.edu/~kstanley/neat.html">NEAT</a>) now incorporate the results of much practical experience.</p>
  
  <p>According to the above link:</p>
  
  <blockquote>
    <p>We also developed an extension to NEAT called HyperNEAT that can evolve neural networks with millions of connections and exploit geometric regularities in the task domain. The HyperNEAT Page includes links to publications and a general explanation of the approach.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-15T21:32:24.090Z
Answers.Text: That "Essentials of Metaheuristics" looks very interesting!  This is something that's actually on the roadmap for the M-automata, as pure MCTS is never optimal in M games.  From the [metaheuristic wiki](https://en.wikipedia.org/wiki/Metaheuristic): *"In computer science and mathematical optimization, a metaheuristic is a higher-level procedure or heuristic designed to find, generate, or select a heuristic (partial search algorithm) that may provide a sufficiently good solution to an optimization problem, especially with incomplete or imperfect information or limited computation capacity."*
Answers.UserDisplayName: DukeZhou
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-15T07:59:57.977Z
Answers.LastActivityDate: 2016-08-15T08:12:41.983Z
Answers.LastEditDate: 2016-08-15T08:12:41.983Z
Answers.UserDisplayName: NietzscheanAI
Body: <p>For a deterministic problem space, I need to find a neural network with the optimal node and link structure. I want to use a genetic algorithm to simulate many neural networks to find the best network structure for the problem domain. </p>
  
  <p>I've never used genetic algorithms for a task like this before. <em>What are the practical considerations? Specifically, how should I encode the structure of a neural network into a genome?</em></p>
  
Tags: <neural-networks><ai-design><genetic-algorithms><evolutionary-algorithms><neuroevolution>
Title: How should I encode the structure of a neural network into a genome?
UserDisplayName: Mithical
ThreadText: # How should I encode the structure of a neural network into a genome?
  
  (Asked by: username_0 on 2016-08-14)
  
  For a deterministic problem space, I need to find a neural network with the optimal node and link structure. I want to use a genetic algorithm to simulate many neural networks to find the best network structure for the problem domain.
  
  I've never used genetic algorithms for a task like this before. *What are the practical considerations? Specifically, how should I encode the structure of a neural network into a genome?*
  
  **Tags:** neural-networks, ai-design, genetic-algorithms, evolutionary-algorithms, neuroevolution
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-08-15. Score: 12 | Accepted answer
  
  Section 4.2 of ["Essentials of Metaheuristics"](https://cs.gmu.edu/~sean/book/metaheuristics/) has a wealth of information on alternative ways of encoding graph structures via Genetic Algorithms.
  
  With particular regard to evolving ANNs, I would personally not be inclined to implement this sort of thing 'from scratch':
  
  The field of neuroevolution has been around for some time, and the implementation some of the methods, such as Neuroevolution of Augmenting Topologies ([NEAT](http://www.cs.ucf.edu/~kstanley/neat.html)) now incorporate the results of much practical experience.
  
  According to the above link:
  
  > We also developed an extension to NEAT called HyperNEAT that can evolve neural networks with millions of connections and exploit geometric regularities in the task domain. The HyperNEAT Page includes links to publications and a general explanation of the approach.
  
  > **Comments:**
  > **username_3**: That "Essentials of Metaheuristics" looks very interesting!  This is something that's actually on the roadmap for the M-automata, as pure MCTS is never optimal in M games.  From the [metaheuristic wiki](https://en.wikipedia.org/wiki/Metaheuristic): *"In computer science and mathematical optimization, a metaheuristic is a higher-level procedure or heuristic designed to find, generate, or select a heuristic (partial search algorithm) that may provide a sufficiently good solution to an optimization problem, especially with incomplete or imperfect information or limited computation capacity."*  
  
  ---
  
  ### Answer by username_1 on 2016-09-06. Score: 4
  
  Using evolutionary algorithms to evolve neural networks is called [neuroevolution](http://www.scholarpedia.org/article/Neuroevolution).
  
  Some neuroevolution algorithms optimize only the *weights* of a neural network with fixed topology. That sounds not like what you want. Other neuroevolution algorithms optimize both the *weights* and *topology* of a neural net. These kinds of algorithms seem more appropriate for your aims, and are sometimes called TWEANNs (Topology and Weight Evolving Neural Networks).
  
  One popular algorithm is called [NEAT](https://www.cs.ucf.edu/~kstanley/neat.html), and is probably a good place to start, if only because there are a multitude of implementations, one of which hopefully is written in your favorite language. That would at least give you a baseline to work with.
  
  NEAT encodes a neural network genome directly as a graph structure. Mutations can operate on the structure of the network by adding new links (by connecting two nodes not previously connected) or new nodes (by splitting an existing connection), or can operate only on changing the weights associated with edges in the graphs (called mutating the weights).
  To give you an idea of the order of magnitude of the sizes of ANNs this particular algorithm works with, it would likely struggle with more than 100 or 200 nodes.
  
  There are more scalable TWEANNs, but they're more complex and make assumptions about the kinds of structures they generate that may not always be productive in practice. For example, another way to encode the structure of a neural network, is as the product of a seed pattern that is repeatedly expanded by a grammar (e.g. an L-system). You can much more easily explore larger structures, but because they're generated by a grammar they'll have a characteristic self-repeating sort of feel. HyperNEAT is a popular extension of NEAT that makes a different sort of assumption (that patterns of weights can be easily expressed as a function of geometry), and can scale to ANNs with millions of connections when that assumption well-fits a particular domain.
  
  There are a few survey papers linked in the top link if you want to observe a greater variety of techniques.
  
  
  ---
  
  