Beispiel #1
0
 public Neuron(Neuron other)
 {
     innovNb      = other.innovNb;
     neurType     = other.neurType;
     Val          = other.Val;
     IsCalculated = other.IsCalculated;
 }
        protected IList <Neuron[]> CreateLayers(
            int startingInnovNb,
            IList <int> layersNeuronCount,
            ENeurType neurType,
            out List <Neuron> allNeurons)
        {
            List <Neuron[]> layers = new List <Neuron[]>();

            allNeurons = new List <Neuron>();

            if (layersNeuronCount == null)
            {
                return(layers);
            }
            foreach (var layerCount in layersNeuronCount)
            {
                var neurons = NewNeurons(
                    startingInnovNb,
                    layerCount,
                    neurType);

                allNeurons.AddRange(neurons);
                startingInnovNb = neurons.Last().innovNb + 1;
                layers.Add(neurons);
            }
            return(layers);
        }
 public static IList <Neuron> GetNeurons(
     INeuralGenome genome,
     ENeurType neurType)
 {
     return(genome.NeuronLst
            .Where(x => x.neurType == neurType)
            .ToArray());
 }
Beispiel #4
0
 public Neuron(
     int innovNb_,
     ENeurType neurType_,
     double val_ = 0d)
 {
     innovNb      = innovNb_;
     neurType     = neurType_;
     Val          = val_;
     IsCalculated = false;
 }
 protected Neuron[] NewNeurons(
     int startingInnovNb,
     int n,
     ENeurType neurType)
 {
     return(Enumerable.Range(0, n)
            .Select(x =>
                    new Neuron(x + startingInnovNb, neurType))
            .ToArray());
 }
 protected Neuron[] GetNeuronsOfType(ENeurType neurType)
 {
     return(Network.Where(kv => kv.Key.neurType == neurType)
            .Select(kv => kv.Key)
            .ToArray());
 }