Inheritance: Encog.ML.BasicML, IMLRegression, IMLResettable, IMLError
Esempio n. 1
0
 public TrainOutstar(CPNNetwork theNetwork, IMLDataSet theTraining, double theLearningRate)
     : base(TrainingImplementationType.Iterative)
 {
     this._x268cb8b20222b0dc = true;
     this._x87a7fc6a72741c2e = theNetwork;
     this._x823a2b9c8bf459c5 = theTraining;
     this._x9b481c22b6706459 = theLearningRate;
 }
Esempio n. 2
0
 private void Validate(CPNNetwork cpn)
 {
     Assert.AreEqual(5, cpn.InputCount);
     Assert.AreEqual(4, cpn.InstarCount);
     Assert.AreEqual(3, cpn.OutputCount);
     Assert.AreEqual(3, cpn.OutstarCount);
     Assert.AreEqual(2, cpn.WinnerCount);
     Assert.AreEqual(5, cpn.WeightsInputToInstar.Rows);
     Assert.AreEqual(4, cpn.WeightsInputToInstar.Cols);
     Assert.AreEqual(4, cpn.WeightsInstarToOutstar.Rows);
     Assert.AreEqual(3, cpn.WeightsInstarToOutstar.Cols);
 }
Esempio n. 3
0
        /// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            IDictionary <String, String> networkParams = null;
            var ins0 = new EncogReadHelper(mask0);
            EncogFileSection section;
            int    inputCount  = 0;
            int    instarCount = 0;
            int    outputCount = 0;
            int    winnerCount = 0;
            Matrix m1          = null;
            Matrix m2          = null;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("CPN") &&
                    section.SubSectionName.Equals("PARAMS"))
                {
                    networkParams = section.ParseParams();
                }
                if (section.SectionName.Equals("CPN") &&
                    section.SubSectionName.Equals("NETWORK"))
                {
                    IDictionary <String, String> paras = section.ParseParams();

                    inputCount = EncogFileSection.ParseInt(paras,
                                                           PersistConst.InputCount);
                    instarCount = EncogFileSection.ParseInt(paras,
                                                            PersistConst.Instar);
                    outputCount = EncogFileSection.ParseInt(paras,
                                                            PersistConst.OutputCount);
                    winnerCount = EncogFileSection.ParseInt(paras,
                                                            PropertyWinnerCount);
                    m1 = EncogFileSection.ParseMatrix(paras,
                                                      PropertyInputToInstar);
                    m2 = EncogFileSection.ParseMatrix(paras,
                                                      PropertyInstarToInput);
                }
            }

            var result = new CPNNetwork(inputCount, instarCount, outputCount,
                                        winnerCount);

            EngineArray.PutAll(networkParams, result.Properties);
            result.WeightsInputToInstar.Set(m1);
            result.WeightsInstarToOutstar.Set(m2);
            return(result);
        }
Esempio n. 4
0
 public object Read(Stream mask0)
 {
     IDictionary<string, string> source = null;
     EncogFileSection section;
     IDictionary<string, string> dictionary2;
     EncogReadHelper helper = new EncogReadHelper(mask0);
     int theInputCount = 0;
     int theInstarCount = 0;
     int theOutstarCount = 0;
     int theWinnerCount = 0;
     Matrix other = null;
     Matrix matrix2 = null;
     goto Label_0097;
     Label_0075:
     if (3 == 0)
     {
         goto Label_00D0;
     }
     if ((((uint) theInstarCount) + ((uint) theOutstarCount)) > uint.MaxValue)
     {
         goto Label_019A;
     }
     Label_0097:
     if ((section = helper.ReadNextSection()) != null)
     {
         if (!section.SectionName.Equals("CPN"))
         {
             goto Label_00D0;
         }
         goto Label_019A;
     }
     CPNNetwork network = new CPNNetwork(theInputCount, theInstarCount, theOutstarCount, theWinnerCount);
     EngineArray.PutAll<string, string>(source, network.Properties);
     if ((((uint) theInputCount) & 0) != 0)
     {
         goto Label_0176;
     }
     network.WeightsInputToInstar.Set(other);
     network.WeightsInstarToOutstar.Set(matrix2);
     if (((uint) theInstarCount) <= uint.MaxValue)
     {
         return network;
     }
     goto Label_00E4;
     Label_00D0:
     if (!section.SectionName.Equals("CPN"))
     {
         goto Label_0097;
     }
     if (((uint) theInstarCount) >= 0)
     {
         if (section.SubSectionName.Equals("NETWORK"))
         {
             dictionary2 = section.ParseParams();
             theInputCount = EncogFileSection.ParseInt(dictionary2, "inputCount");
             goto Label_0176;
         }
         if (((uint) theInstarCount) >= 0)
         {
             goto Label_0097;
         }
         goto Label_0075;
     }
     return network;
     Label_00E4:
     theWinnerCount = EncogFileSection.ParseInt(dictionary2, "winnerCount");
     other = EncogFileSection.ParseMatrix(dictionary2, "inputToInstar");
     matrix2 = EncogFileSection.ParseMatrix(dictionary2, "instarToInput");
     if (2 != 0)
     {
         goto Label_0075;
     }
     goto Label_00D0;
     Label_0176:
     theInstarCount = EncogFileSection.ParseInt(dictionary2, "instar");
     if (((uint) theWinnerCount) >= 0)
     {
         theOutstarCount = EncogFileSection.ParseInt(dictionary2, "outputCount");
         if ((((uint) theInputCount) + ((uint) theInstarCount)) < 0)
         {
             goto Label_019A;
         }
     }
     goto Label_00E4;
     Label_019A:
     if (section.SubSectionName.Equals("PARAMS"))
     {
         source = section.ParseParams();
     }
     goto Label_00D0;
 }
Esempio n. 5
0
        public void Test(CPNNetwork network, String[][] pattern, double[][] input)
        {
            for (int i = 0; i < pattern.Length; i++)
            {
                IMLData inputData = new BasicMLData(input[i]);
                IMLData outputData = network.Compute(inputData);
                double angle = DetermineAngle(outputData);

                // display image
                for (int j = 0; j < HEIGHT; j++)
                {
                    if (j == HEIGHT - 1)
                        app.WriteLine("[" + pattern[i][j] + "] -> " + ((int) angle) + " deg");
                    else
                        app.WriteLine("[" + pattern[i][j] + "]");
                }

                Console.WriteLine();
            }
        }
Esempio n. 6
0
        public void TrainOutstar(CPNNetwork network, IMLDataSet training)
        {
            int epoch = 1;

            IMLTrain train = new TrainOutstar(network, training, 0.1);
            for (int i = 0; i < 1000; i++)
            {
                train.Iteration();
                app.WriteLine("Training outstar, Epoch #" + epoch);
                epoch++;
            }
        }
        /// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            IDictionary<String, String> networkParams = null;
            var ins0 = new EncogReadHelper(mask0);
            EncogFileSection section;
            int inputCount = 0;
            int instarCount = 0;
            int outputCount = 0;
            int winnerCount = 0;
            Matrix m1 = null;
            Matrix m2 = null;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("CPN")
                    && section.SubSectionName.Equals("PARAMS"))
                {
                    networkParams = section.ParseParams();
                }
                if (section.SectionName.Equals("CPN")
                    && section.SubSectionName.Equals("NETWORK"))
                {
                    IDictionary<String, String> paras = section.ParseParams();

                    inputCount = EncogFileSection.ParseInt(paras,
                                                           PersistConst.InputCount);
                    instarCount = EncogFileSection.ParseInt(paras,
                                                            PersistConst.Instar);
                    outputCount = EncogFileSection.ParseInt(paras,
                                                            PersistConst.OutputCount);
                    winnerCount = EncogFileSection.ParseInt(paras,
                                                            PropertyWinnerCount);
                    m1 = EncogFileSection.ParseMatrix(paras,
                                                      PropertyInputToInstar);
                    m2 = EncogFileSection.ParseMatrix(paras,
                                                      PropertyInstarToInput);
                }
            }

            var result = new CPNNetwork(inputCount, instarCount, outputCount,
                                        winnerCount);
            EngineArray.PutAll(networkParams, result.Properties);
            result.WeightsInputToInstar.Set(m1);
            result.WeightsInstarToOutstar.Set(m2);
            return result;
        }
Esempio n. 8
0
 private CPNNetwork Create()
 {
     CPNNetwork result = new CPNNetwork(5, 4, 3, 2);
     return result;
 }