Beispiel #1
0
        /// <summary>
        /// Calculate the error for the specified data set. The error is the largest distance.
        /// </summary>
        /// <param name="data">The data set to check.</param>
        /// <returns>The error.</returns>
        public double CalculateError(IMLDataSet data)
        {
            var bmu = new BestMatchingUnit(this);

            bmu.Reset();

            // Determine the BMU for each training element.
            foreach (IMLDataPair pair in data)
            {
                IMLData input = pair.Input;
                bmu.CalculateBMU(input);
            }

            // update the error
            return(bmu.WorstDistance / 100.0);
        }
Beispiel #2
0
        /// <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 BasicTrainSOM(SelfOrganizingMap network, double learningRate,
                             IList <BasicData> training, INeighborhoodFunction neighborhood)
        {
            _neighborhood      = neighborhood;
            _training          = training;
            LearningRate       = learningRate;
            _network           = network;
            _inputNeuronCount  = network.InputCount;
            _outputNeuronCount = network.OutputCount;
            ForceWinner        = false;
            _error             = 0;

            // setup the correction matrix
            _correctionMatrix = DenseMatrix.Create(_outputNeuronCount, _inputNeuronCount, 0);

            // create the BMU class
            _bmuUtil = new BestMatchingUnit(network);
        }
Beispiel #3
0
        /// <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 BasicTrainSOM(SelfOrganizingMap network, double learningRate,
            IList<BasicData> training, INeighborhoodFunction neighborhood)
        {
            _neighborhood = neighborhood;
            _training = training;
            LearningRate = learningRate;
            _network = network;
            _inputNeuronCount = network.InputCount;
            _outputNeuronCount = network.OutputCount;
            ForceWinner = false;
            _error = 0;

            // setup the correction matrix
            _correctionMatrix = DenseMatrix.Create(_outputNeuronCount, _inputNeuronCount, 0);

            // create the BMU class
            _bmuUtil = new BestMatchingUnit(network);
        }