public NeuralNetwork(int numberOfInputs, int numberOfHidden, int numberOfOutput, Matrix.Matrix inputs) { learningRate = 0.1; momentumRate = 0.5; numberOfHiddenNeurons = numberOfHidden; inp = inputs; hiddenOutput = new Matrix.Matrix(numberOfHidden, numberOfInputs); outputWeights = new Matrix.Matrix(numberOfOutput, numberOfHidden); centre = new Matrix.Matrix(numberOfHidden, numberOfInputs); range = new Matrix.Matrix(numberOfHidden, 1); //hiddenOutput.RandomizeMatrix(-1, 1); outputWeights.RandomizeMatrix(-5, 5); Random rnd = new Random(); for (int i = 0; i < numberOfHidden; ++i) { //wypełnianie macierzy c - centrów int index = rnd.Next(0, inputs.row); for (int j = 0; j < numberOfInputs; ++j) { centre.tab[i, j] = inputs.tab[index, j]; //Console.WriteLine(centre.tab[i, j]); } //wypełnianie macierzy r - zasięgu range.tab[i, 0] = rnd.NextDouble() * 1; } }
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); }
public NeuralNetwork(int inputAmount, int hiddenAmount, int outputAmount, bool bias) { learningRate = 0.5; momentumRate = 0.5; useBias = bias; hiddenWeights = new Matrix.Matrix(hiddenAmount, inputAmount); // 2 x 3 outputWeights = new Matrix.Matrix(outputAmount, hiddenAmount); // 1 x 2 momentumMatrixHidden = new Matrix.Matrix(hiddenAmount, inputAmount); momentumMatrixOutput = new Matrix.Matrix(outputAmount, hiddenAmount); hiddenWeights.RandomizeMatrix(-1, 1); outputWeights.RandomizeMatrix(-1, 1); biasHidden = new Matrix.Matrix(hiddenAmount, 1); biasOutput = new Matrix.Matrix(outputAmount, 1); momentumMatrixHiddenBias = new Matrix.Matrix(hiddenAmount, 1); momentumMatrixOutputBias = new Matrix.Matrix(outputAmount, 1); biasHidden.RandomizeMatrix(-1, 1); biasOutput.RandomizeMatrix(-1, 1); }