コード例 #1
0
        private IGenomeListEvaluator <NeatGenome <double> > CreateGenomeListEvaluator(
            out int inputCount, out int outputCount)
        {
            var genomeDecoder = NeatGenomeDecoderFactory.CreateGenomeAcyclicDecoder(true);
            IBlackBoxEvaluationScheme <double> blackBoxEvaluationScheme = new BinaryElevenMultiplexerEvaluationScheme();

            //// Create function regression evaluation scheme.
            //int sampleResolution = 20;
            //double sampleMin = 0;
            //double sampleMax = 6.283185;
            //var paramSamplingInfo = new ParamSamplingInfo(sampleMin, sampleMax, sampleResolution);
            //IBlackBoxEvaluationScheme<double> blackBoxEvaluationScheme = new FuncRegressionEvaluationScheme(FunctionFactory.GetFunction(FunctionId.Sin), paramSamplingInfo, 0.3);

            var genomeListEvaluator = GenomeListEvaluatorFactory.CreateEvaluator(
                genomeDecoder,
                blackBoxEvaluationScheme,
                createConcurrentEvaluator: true);

            inputCount  = blackBoxEvaluationScheme.InputCount;
            outputCount = blackBoxEvaluationScheme.OutputCount;
            return(genomeListEvaluator);
        }
コード例 #2
0
        private void TestCorrectResponseInner(bool suppressHardwareAcceleration)
        {
            var activationFnFactory = new DefaultActivationFunctionFactory <double>(suppressHardwareAcceleration);
            var metaNeatGenome      = new MetaNeatGenome <double>(4, 1, true, activationFnFactory.GetActivationFunction("LeakyReLU"));

            // Load test genome.
            NeatGenomeLoader <double> loader = NeatGenomeLoaderFactory.CreateLoaderDouble(metaNeatGenome);
            NeatGenome <double>       genome = loader.Load("TestData/binary-three-multiplexer.genome");

            // Decode genome to a neural net.
            var genomeDecoder           = NeatGenomeDecoderFactory.CreateGenomeAcyclicDecoder(true);
            IBlackBox <double> blackBox = genomeDecoder.Decode(genome);

            // Evaluate the neural net.
            var evaluator = new BinaryThreeMultiplexerEvaluator();

            // Confirm the expected fitness (to a limited amount of precision to allow for small variations of floating point
            // results that can occur as a result of platform/environmental variations).
            FitnessInfo fitnessInfo = evaluator.Evaluate(blackBox);

            Assert.AreEqual(107.50554956432657, fitnessInfo.PrimaryFitness, 0.000001);
        }