private static IGenomeDecoder <NeatGenome <double>, IBlackBox <double> > CreateGenomeDecoder( INeatExperiment <double> neatExperiment) { if (neatExperiment.IsAcyclic) { return(NeatGenomeDecoderFactory.CreateGenomeDecoderAcyclic( neatExperiment.EnableHardwareAcceleratedNeuralNets)); } return(NeatGenomeDecoderFactory.CreateGenomeDecoderCyclic( neatExperiment.CyclesPerActivation, neatExperiment.EnableHardwareAcceleratedNeuralNets)); }
private static void VerifyNeuralNetResponseInner(bool enableHardwareAcceleration) { var activationFnFactory = new DefaultActivationFunctionFactory <double>(enableHardwareAcceleration); 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.CreateGenomeDecoderAcyclic(); 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.Equal(107.50554956432657, fitnessInfo.PrimaryFitness, 6); }
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); }