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; }
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; }
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; }
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; }
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; }
/// <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]); } }