Exemple #1
0
        /// <summary>
        /// Construct the trainer for a self organizing map.
        /// </summary>
        /// <param name="som">The self organizing map.</param>
        /// <param name="train">The training method.</param>
        /// <param name="learnMethod">The learning method.</param>
        /// <param name="learnRate">The learning rate.</param>
        public TrainSelfOrganizingMap(SelfOrganizingMap som,
                                      double[][] train, LearningMethod learnMethod, double learnRate)
        {
            this.som         = som;
            this.train       = train;
            this.totalError  = 1.0;
            this.learnMethod = learnMethod;
            this.learnRate   = learnRate;

            this.outputNeuronCount = som.OutputNeuronCount;
            this.inputNeuronCount  = som.InputNeuronCount;

            this.totalError = 1.0;

            for (int tset = 0; tset < train.Length; tset++)
            {
                Matrix.Matrix dptr = Matrix.Matrix.CreateColumnMatrix(train[tset]);
                if (MatrixMath.vectorLength(dptr) < VERYSMALL)
                {
                    throw (new System.Exception(
                               "Multiplicative normalization has null training case"));
                }
            }

            this.bestnet = new SelfOrganizingMap(this.inputNeuronCount,
                                                 this.outputNeuronCount, this.som.NormalizationType);

            this.won    = new int[this.outputNeuronCount];
            this.correc = new Matrix.Matrix(this.outputNeuronCount,
                                            this.inputNeuronCount + 1);
            if (this.learnMethod == LearningMethod.ADDITIVE)
            {
                this.work = new Matrix.Matrix(1, this.inputNeuronCount + 1);
            }
            else
            {
                this.work = null;
            }

            Initialize();
            this.bestError = Double.MaxValue;
        }
        /// <summary>
        /// Copy the weights from one matrix to another.
        /// </summary>
        /// <param name="source">The source SOM.</param>
        /// <param name="target">The target SOM.</param>
        private void CopyWeights(SelfOrganizingMap source,
                 SelfOrganizingMap target)
        {

            MatrixMath.Copy(source.OutputWeights, target
                    .OutputWeights);
        }
        /// <summary>
        /// Construct the trainer for a self organizing map.
        /// </summary>
        /// <param name="som">The self organizing map.</param>
        /// <param name="train">The training method.</param>
        /// <param name="learnMethod">The learning method.</param>
        /// <param name="learnRate">The learning rate.</param>
        public TrainSelfOrganizingMap(SelfOrganizingMap som,
                 double[][] train, LearningMethod learnMethod, double learnRate)
        {
            this.som = som;
            this.train = train;
            this.totalError = 1.0;
            this.learnMethod = learnMethod;
            this.learnRate = learnRate;

            this.outputNeuronCount = som.OutputNeuronCount;
            this.inputNeuronCount = som.InputNeuronCount;

            this.totalError = 1.0;

            for (int tset = 0; tset < train.Length; tset++)
            {
                Matrix.Matrix dptr = Matrix.Matrix.CreateColumnMatrix(train[tset]);
                if (MatrixMath.vectorLength(dptr) < VERYSMALL)
                {
                    throw (new System.Exception(
                            "Multiplicative normalization has null training case"));
                }

            }

            this.bestnet = new SelfOrganizingMap(this.inputNeuronCount,
                    this.outputNeuronCount, this.som.NormalizationType);

            this.won = new int[this.outputNeuronCount];
            this.correc = new Matrix.Matrix(this.outputNeuronCount,
                    this.inputNeuronCount + 1);
            if (this.learnMethod == LearningMethod.ADDITIVE)
            {
                this.work = new Matrix.Matrix(1, this.inputNeuronCount + 1);
            }
            else
            {
                this.work = null;
            }

            Initialize();
            this.bestError = Double.MaxValue;
        }
Exemple #4
0
 /// <summary>
 /// Copy the weights from one matrix to another.
 /// </summary>
 /// <param name="source">The source SOM.</param>
 /// <param name="target">The target SOM.</param>
 private void CopyWeights(SelfOrganizingMap source,
                          SelfOrganizingMap target)
 {
     MatrixMath.Copy(source.OutputWeights, target
                     .OutputWeights);
 }