Exemplo n.º 1
0
        public TeacherTester()
        {
            Logger.Log(this, "App start");

            NodeFuncGenerator funcGenerator = new NodeFuncGenerator();
            Dictionary<NodeType, double> nodeProbabilityMap = new Dictionary<NodeType, double>()
            {
                {NodeType.add, 1.0d},
                {NodeType.compare, 1.0d},
                {NodeType.copy, 0.0d},
                {NodeType.inverse, 1.0d},
                {NodeType.log, 1.0d},
                {NodeType.multiply, 1.0d},
                {NodeType.reverse, 1.0d}
            };
            NodeFactory nodeFactory = new NodeFactory(funcGenerator, nodeProbabilityMap);
            List<DataPoint> dataPoints = GenerateSinWaveDataPoints(100, 0.19d);
            Network network = new Network(nodeFactory, dataPoints, 1000);
            double addRemoveChance = 0.5;
            PatchFactory patchFactory = new PatchFactory(network, nodeFactory, addRemoveChance);
            NetworkTeacher networkTeacher = new NetworkTeacher(network, patchFactory);

            Logger.Log(this, String.Format("initial error: {0}", network.CalculateTrainingSqrError()));
            networkTeacher.Teach(
                teachingTime: TimeSpan.FromSeconds(10000000.0d),
                wantedNoOfNodes: 300,
                changesPerPatch: 8,
                patchesPerTeachingSerie: 1
            );
            Logger.Log(this, String.Format("error after learning: {0}", network.CalculateTrainingSqrError()));

            Logger.Log(this, "App finish");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="network"></param>
        /// <param name="nodeFactory"></param>
        /// <param name="addRemoveChance">chance in range <0, 1> - rest is chance of tranformation</param>
        public PatchFactory(Network network, NodeFactory nodeFactory, double addRemoveChance)
        {
            if (addRemoveChance < 0.0d || addRemoveChance > 1.0d)
                throw new ArgumentOutOfRangeException("addRemoveChance");

            network_ = network;
            nodeFactory_ = nodeFactory;
            addRemoveChance_ = addRemoveChance;
        }
 public void SetUp()
 {
     NodeFuncGenerator nodeFuncGenerator = new NodeFuncGenerator();
     NodeFactory nodeFactory = new NodeFactory(
         nodeFuncGenerator,
         new Dictionary<NodeType, double>() { { NodeType.add, 1.0d } });
     network = new Network(
         nodeFactory: nodeFactory,
         trainingData: new List<DataPoint>()
         {
             new DataPoint(new List<double>(){2.0d, 2.0d, 2.0d}, 5.0d) //IMPORTANT: TODO: was modified from "new DataPoint(new List<double>(){2.0d, 2.0d}, 5.0d)" - now test can work incorrectly
         },
         maxHierarchy: 1000
     );
     patchFactory = new PatchFactory(network, nodeFactory, 1.0d);
     networkTeacher = new NetworkTeacher(network, patchFactory);
 }
        public void SinWaveTrainingTest()
        {
            NodeFuncGenerator funcGenerator = new NodeFuncGenerator();
            Dictionary<NodeType, double> nodeProbabilityMap = new Dictionary<NodeType,double>()
            {
                {NodeType.add, 1.0d},
                {NodeType.compare, 1.0d},
                {NodeType.copy, 0.0d},
                {NodeType.inverse, 1.0d},
                {NodeType.log, 1.0d},
                {NodeType.multiply, 1.0d},
                {NodeType.reverse, 1.0d}
            };
            NodeFactory nodeFactory = new NodeFactory(funcGenerator, nodeProbabilityMap);
            List<DataPoint> dataPoints = GenerateSinWaveDataPoints(100, 0.35d);
            Network network = new Network(nodeFactory, dataPoints, 1000);
            double addRemoveChance = 0.5;
            PatchFactory patchFactory = new PatchFactory(network, nodeFactory, addRemoveChance);
            NetworkTeacher networkTeacher = new NetworkTeacher(network, patchFactory);

            networkTeacher.Teach(TimeSpan.FromSeconds(0.1d), 2000, 3, 30);
        }
Exemplo n.º 5
0
            Assert.AreEqual(0, child3.Outputs.Count);

            dummyNetwork.UTTestingFoo();
        }