Exemple #1
0
 private void BTrain_Click(object sender, EventArgs e)
 {
     if (Data.Count != 0)
     {
         KMeans k = new KMeans((int)NiDCentroidsAmount.Value, Data, rnd, pB);
         k.Train();
         Error = k.Error;
     }
 }
Exemple #2
0
        public NeuralNetwork(int numberOfInputs, int numberOfHidden, int numberOfOutput, bool bias, Matrix.Matrix inputs)
        {
            learningRate = 0.001;
            momentumRate = 0.002;
            useBias      = bias;

            numberOfHiddenNeurons = numberOfHidden;

            inp = inputs;

            hiddenOutput  = new Matrix.Matrix(numberOfHidden, 1);
            outputWeights = new Matrix.Matrix(numberOfOutput, numberOfHidden);

            range = new Matrix.Matrix(numberOfHidden, 1);

            //hiddenOutput.RandomizeMatrix(-1, 1);
            outputWeights.RandomizeMatrix(-1, 1);

            Random rnd = new Random();

            List <Kmeans.Point> Data = new List <Kmeans.Point>();

            for (int i = 0; i < inputs.row; i++)
            {
                Data.Add(new Kmeans.Point(inputs.tab[i, 0], inputs.tab[i, 1], inputs.tab[i, 2], inputs.tab[i, 3]));
            }

            var km = new Kmeans.KMeans(numberOfHidden, Data, rnd);

            km.Train();
            Console.WriteLine("centroids done");

            centre = km.Centroids;

            for (int i = 0; i < numberOfHidden; ++i)
            {
                //wypełnianie macierzy r - zasięgu
                range.tab[i, 0] =
                    setRange(centre[i]) * beta;
            }
            momentumMatrixOutput     = new Matrix.Matrix(numberOfOutput, numberOfHidden);
            biasOutput               = new Matrix.Matrix(numberOfOutput, 1);
            momentumMatrixOutputBias = new Matrix.Matrix(numberOfOutput, 1);

            biasOutput.RandomizeMatrix(-1, 1);
        }