/// <summary> /// Create an instance of competitive training. /// </summary> /// <param name="network">The network to train.</param> /// <param name="learningRate">The learning rate, how much to apply per iteration.</param> /// <param name="training">The training set (unsupervised).</param> /// <param name="neighborhood">The neighborhood function to use.</param> public CompetitiveTraining(BasicNetwork network, double learningRate, INeuralDataSet training, INeighborhoodFunction neighborhood) { this.neighborhood = neighborhood; Training = training; this.LearningRate = learningRate; this.network = network; this.inputLayer = network.GetLayer(BasicNetwork.TAG_INPUT); this.outputLayer = network.GetLayer(BasicNetwork.TAG_OUTPUT); this.synapses = network.Structure.GetPreviousSynapses( this.outputLayer); this.inputNeuronCount = this.inputLayer.NeuronCount; this.outputNeuronCount = this.outputLayer.NeuronCount; this.ForceWinner = false; Error = 0; // setup the correction matrix foreach (ISynapse synapse in this.synapses) { Matrix matrix = new Matrix(synapse.WeightMatrix.Rows, synapse.WeightMatrix.Cols); this.correctionMatrix[synapse] = matrix; } // create the BMU class this.bmuUtil = new BestMatchingUnit(this); }
/// <summary> /// Create an instance of competitive training. /// </summary> /// <param name="network">The network to train.</param> /// <param name="learningRate">The learning rate, how much to apply per iteration.</param> /// <param name="training">The training set (unsupervised).</param> /// <param name="neighborhood">The neighborhood function to use.</param> public CompetitiveTraining(BasicNetwork network, double learningRate, INeuralDataSet training, INeighborhoodFunction neighborhood) { this.neighborhood = neighborhood; Training = training; this.LearningRate = learningRate; this.network = network; this.inputLayer = network.GetLayer(BasicNetwork.TAG_INPUT); this.outputLayer = network.GetLayer(BasicNetwork.TAG_OUTPUT); this.synapses = network.Structure.GetPreviousSynapses( this.outputLayer); this.inputNeuronCount = this.inputLayer.NeuronCount; this.outputNeuronCount = this.outputLayer.NeuronCount; this.ForceWinner = false; Error = 0; // setup the correction matrix foreach (ISynapse synapse in this.synapses) { Matrix matrix = new Matrix(synapse.WeightMatrix.Rows, synapse.WeightMatrix.Cols); this.correctionMatrix[synapse] = matrix; } // create the BMU class this.bmuUtil = new BestMatchingUnit(this); }