예제 #1
0
        public static InputVector operator +(InputVector v1, InputVector v2)
        {
            InputVector result = new InputVector();

            for (int i = 0; i < SOMConstants.NUM_WEIGHTS; ++i)
            {
                result.weights[i] = v1.weights[i] + v2.weights[i];
            }

            return result;
        }
예제 #2
0
        public ImageData()
        {
            m_vectorHistogram = new float[SOMConstants.INPUT_VECTOR_SIZE_HISTOGRAM];
            m_vectorArea = new float[SOMConstants.INPUT_VECTOR_SIZE_AREA];

            // ccd feature initialization
            CEDD = new float[144];
            FCTH = new float[192];
            JCD = new float[168];

            inputVector = new InputVector();
            m_BMU.X = -1; m_BMU.Y = -1;
        }
예제 #3
0
파일: SOM.cs 프로젝트: pyephyomaung/som-ar
        private Neuron FindBMU(InputVector inputVec)
        {
            Neuron winner = null;

            float lowestDistance = float.MaxValue;

            for (int i = 0; i < SOMConstants.NUM_NODES_DOWN; ++i)
            {
                for (int j = 0; j < SOMConstants.NUM_NODES_ACROSS; ++j)
                {
                    float dist = SOMHelper.Calculate_Distance(_competitionLayer[i, j].Weights, inputVec.weights);

                    if (dist < lowestDistance)
                    {
                        lowestDistance = dist;
                        winner = _competitionLayer[i, j];
                    }
                }
            }

            System.Diagnostics.Debug.Assert(winner != null);
            return winner;
        }
예제 #4
0
파일: SOM.cs 프로젝트: pyephyomaung/som-ar
        public Neuron Recognize(InputVector inputVec)
        {
            Neuron winner = null;
            if (IsTrained)
            {
                float lowestDistance = float.MaxValue;

                for (int i = 0; i < SOMConstants.NUM_NODES_DOWN; ++i)
                {
                    for (int j = 0; j < SOMConstants.NUM_NODES_ACROSS; ++j)
                    {
                        if (_competitionLayer[i, j].GetImageCount() > 0)
                        {
                            float dist = SOMHelper.Calculate_Distance(_competitionLayer[i, j].Weights, inputVec.weights);

                            if (dist < lowestDistance)
                            {
                                lowestDistance = dist;
                                winner = _competitionLayer[i, j];
                            }
                        }
                    }
                }

                System.Diagnostics.Debug.Assert(winner != null);
                return winner;
            }
            return winner;
        }
예제 #5
0
        public float CalculateDistanceSquared(InputVector inputVec)
        {
            float distance = 0.0f;

            for ( int i = 0; i < inputVec.weights.Length; ++i ) {
                distance += (inputVec.weights[ i ] - this._Weights[ i ]) *
                    (inputVec.weights[ i ] - this._Weights[ i ]);
            }

            return distance;
        }
예제 #6
0
 /// <summary>
 /// Calculates the new weight for this node.
 /// Equation: W(t+1) = W(t) + THETA(t)*L(t)*(V(t) - W(t)) 
 /// </summary>
 /// <param name="targetVector"></param>
 /// <param name="learningRate"></param>
 /// <param name="influence"></param>
 public void AdjustWeights(InputVector targetVector, float learningRate, float influence)
 {
     for (int w = 0; w < targetVector.weights.Length; ++w)
     {
         this._Weights[w] += learningRate * influence * (targetVector.weights[w] - this._Weights[w]);
     }
 }