コード例 #1
0
ファイル: ImageData.cs プロジェクト: pyephyomaung/som-ar
        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
ファイル: ImageData.cs プロジェクト: pyephyomaung/som-ar
        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
ファイル: Neuron.cs プロジェクト: pyephyomaung/som-ar
        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
ファイル: Neuron.cs プロジェクト: pyephyomaung/som-ar
 /// <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]);
     }
 }