Exemple #1
0
 virtual protected void Calculate(float[] dataArr, float[] outArr)
 {
     double[] outData = _net.Compute(_sampleTestData);
     for (int i = 0; i < outData.Length; i++)
     {
         outArr[i] = (float)outData[i];
     }
 }
Exemple #2
0
        static NEATNetworkTest()
        {
            // Create Network
            _net                  = new NEATNetwork();
            _net.InputCount       = _inputCount;
            _net.OutputCount      = _outputCount;
            _net.ActivationCycles = 4;
            _net.OutputIndex      = _net.InputCount + 1;

            _net.Links = new NEATLink[(int)(_net.InputCount * _net.OutputCount * 1.5)];
            Random rand = new Random();

            for (int i = 0; i < _net.Links.Length; i++)
            {
                _net.Links[i] = new NEATLink()
                {
                    FromNeuron = rand.Next(_net.Links.Length),
                    ToNeuron   = rand.Next(_net.Links.Length),
                    Weight     = (rand.NextDouble() - 0.5) * 0.02,
                };
            }
            _net.PreActivation  = new double[_net.Links.Length];
            _net.PostActivation = new double[_net.Links.Length];


            // Create sampleData;
            _sampleTestData   = new double[_inputCount];
            _sampleResultData = new double[_outputCount];

            for (int i = 0; i < _inputCount; i++)
            {
                _sampleTestData[i] = rand.NextDouble() * 2 - 1;
            }

            _sampleResultData = _net.Compute(_sampleTestData);
        }
        static NEATNetworkTest()
        {
            // Create Network
            _net = new NEATNetwork();
            _net.InputCount = _inputCount;
            _net.OutputCount = _outputCount;
            _net.ActivationCycles = 4;
            _net.OutputIndex = _net.InputCount + 1;

            _net.Links = new NEATLink[(int)(_net.InputCount * _net.OutputCount * 1.5)];
            Random rand = new Random();
            for (int i = 0; i < _net.Links.Length; i++)
            {
                _net.Links[i] = new NEATLink()
                {
                    FromNeuron = rand.Next(_net.Links.Length),
                    ToNeuron = rand.Next(_net.Links.Length),
                    Weight = (rand.NextDouble() - 0.5) * 0.02,
                };
            }
            _net.PreActivation = new double[_net.Links.Length];
            _net.PostActivation = new double[_net.Links.Length];

            // Create sampleData;
            _sampleTestData = new double[_inputCount];
            _sampleResultData = new double[_outputCount];

            for (int i = 0; i < _inputCount; i++)
            {
                _sampleTestData[i] = rand.NextDouble() * 2 - 1;
            }

            _sampleResultData = _net.Compute(_sampleTestData);
        }