Esempio n. 1
0
    private void ProcessPoints()
    {
        switch (m_mode)
        {
        case ExampleMode.Recognize:
            PropagateResult result = PartyRecognitionManager.Instance.Recognize(m_points.ToArray());
            //string highestPattern;
            //float highestScore = result.GetHighestScore(out highestPattern);
            //Debug.Log("Result: " + (highestScore > PartyRecognitionManager.Instance.SuccessThresholdPercent) + "Score: " + result.GetHighestScore(out highestPattern) + " PatternName: "+ result.HighestPattern);
            result.PrettyPrint();
            break;

        case ExampleMode.SavePattern:
            PRPatternDefinition newPattern = new PRPatternDefinition(m_points, (int)PartyRecognitionManager.Instance.DefaultNeuronNumberInput, m_exampleUI.GetPatternName());
            newPattern.NormalizePoints();
            PartyRecognitionManager.Instance.AddPattern(newPattern);
            break;
        }

        m_points.Clear();
        for (int i = 0; i < m_instantiatedObjects.Count; i++)
        {
            Destroy(m_instantiatedObjects[i]);
        }
    }
Esempio n. 2
0
    public PropagateResult Propagate(List <float> angles, float successThreshold)
    {
        float sum2 = 0f;

        if (angles.Count != m_neuronsNumberInp)
        {
            throw new Exception("Angles doesn't match with the Neuron Input dimension");
        }
        for (int i = 0; i < m_neuronsNumberInp; i++)
        {
            m_inpA[i] = angles[i];
        }
        for (int i = 0; i < m_neuronsNumberHid; i++)
        {
            for (int n = 0; n < m_neuronsNumberInp; n++)
            {
                sum2 += m_hidW[i][n] * m_inpA[n];
            }
            m_hidA[i] = Sigmoid(sum2);
        }

        PropagateResult result = new PropagateResult();

        for (int i = 0; i < m_neuronsNumberOut; i++)
        {
            sum2 = 0f;
            for (int n = 0; n < m_neuronsNumberHid; n++)
            {
                sum2 += m_outW[i][n] * m_hidA[n];
            }
            m_outA[i] = Sigmoid(sum2);
            result.AddScore(m_patternId[i], m_outA[i]);
        }

        return(result);
    }
Esempio n. 3
0
    public bool Recognize(Vector2[] points, string patternId, float threshold)
    {
        PropagateResult result = Recognize(points);

        return(result.GetScore(patternId) >= threshold);
    }