[mlpack-git] [mlpack/mlpack] CNE algorithm (#753)

Marcus Edel notifications at github.com
Mon Aug 8 17:06:04 EDT 2016


> +  }
> +
> +  // Add link.
> +  void AddLink(LinkGene& linkGene) {
> +    aLinkGenes.push_back(linkGene);
> +  }
> +
> +  // Add neuron.
> +  void AddHiddenNeuron(NeuronGene& neuronGene) {
> +    if (neuronGene.Type() == HIDDEN) {
> +      aNeuronGenes.push_back(neuronGene);
> +    }
> +  }
> +
> +  // Show genome structure.
> +  void Show() {

Every class you like to serialize should implement the Serialize, in case of the Genome I guess the important parameter you like to serialize is the list of genes and links and some other parameter like fitness:
```
template<typename Archive>
void Serialize(Archive& ar, const unsigned int /* version */)
{
  ar & data::CreateNVP(neuronGenes, "neuronGenes");
  ar & data::CreateNVP(linkGenes, "linkGenes");
  ar & data::CreateNVP(fitness, "fitness");
}
```

You can save a model (Genome) using:

```
Genome genome;
data::Save("output_model_file.xml", "genome_model", genome);
```

Loading is also simple:

```
Genome genome;
data::Load("input_model_file.xml"), "genome_model", genome);
```

Also you might find: https://github.com/mlpack/mlpack/wiki/DesignGuidelines#requirements-of-each-class helpful

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/753/files/10b99ab5c6e8d2836d231fa60a898cc03f7d9192#r73954648
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160808/84959799/attachment.html>


More information about the mlpack-git mailing list