Пример #1
0
 public double CalculateError(IMLDataSet data)
 {
     BestMatchingUnit unit = new BestMatchingUnit(this);
     unit.Reset();
     foreach (IMLDataPair pair in data)
     {
         IMLData input = pair.Input;
         unit.CalculateBMU(input);
     }
     return (unit.WorstDistance / 100.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(SOMNetwork network, double learningRate,
                             IMLDataSet training, INeighborhoodFunction neighborhood)
            : base(TrainingImplementationType.Iterative)
        {
            _neighborhood      = neighborhood;
            Training           = training;
            LearningRate       = learningRate;
            _network           = network;
            _inputNeuronCount  = network.InputCount;
            _outputNeuronCount = network.OutputCount;
            ForceWinner        = false;

            // setup the correction matrix
            _correctionMatrix = new Matrix(_outputNeuronCount, _inputNeuronCount);

            // create the BMU class
            _bmuUtil = new BestMatchingUnit(network);
        }
Пример #3
0
 public BasicTrainSOM(SOMNetwork network, double learningRate, IMLDataSet training, INeighborhoodFunction neighborhood)
     : base(TrainingImplementationType.Iterative)
 {
     this._x3d0ce91dbd8e0b1b = neighborhood;
     while (true)
     {
         this.Training = training;
         while (0 == 0)
         {
             this._x9b481c22b6706459 = learningRate;
             this._x87a7fc6a72741c2e = network;
             this._x57202a8751db8895 = network.InputCount;
             this._x0c37ff3adde9bc44 = network.OutputCount;
             this._xf7c1f63ae5cd87f7 = false;
             this.Error = 0.0;
             this._x42cc0dadfb982948 = new Matrix(this._x57202a8751db8895, this._x0c37ff3adde9bc44);
             this._x703660d5c67ed8fb = new BestMatchingUnit(network);
             if (0 == 0)
             {
                 return;
             }
         }
     }
 }
Пример #4
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(SOMNetwork network, double learningRate,
                             IMLDataSet training, INeighborhoodFunction neighborhood)
            : base(TrainingImplementationType.Iterative)
        {
            _neighborhood = neighborhood;
            Training = training;
            LearningRate = learningRate;
            _network = network;
            _inputNeuronCount = network.InputCount;
            _outputNeuronCount = network.OutputCount;
            ForceWinner = false;

            // setup the correction matrix
            _correctionMatrix = new Matrix(_outputNeuronCount, _inputNeuronCount);

            // create the BMU class
            _bmuUtil = new BestMatchingUnit(network);
        }
        /// <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;
        }