Exemple #1
0
    public static Matriz SinglePointCross(Matriz m1, Matriz m2)
    {
        Matriz mr          = new Matriz(m1.rows, m1.columns);
        int    crosspointC = UnityEngine.Random.Range(0, m1.columns);
        int    crosspointR = UnityEngine.Random.Range(0, m1.rows);

        if (m1.columns == m2.columns && m1.rows == m2.rows)
        {
            for (int i = 0; i < m1.rows; i++)
            {
                for (int j = 0; j < m1.columns; j++)
                {
                    if (i < crosspointC || j < crosspointR)
                    //if(i < crosspointC)
                    {
                        mr.SetAt(i, j, m1.GetAt(i, j));
                    }
                    else
                    {
                        mr.SetAt(i, j, m2.GetAt(i, j));
                    }
                }
            }
            return(mr);
        }
        UnityEngine.Debug.LogError("BAD SINGLEPOINTCROSS");
        return(null);
    }
Exemple #2
0
    public static Matriz operator *(Matriz m1, Matriz m2)
    {
        Matriz mat2 = new Matriz(0, 0);

        if (m1.columns == m2.rows)
        {
            Matriz mat3 = new Matriz(m1.rows, m2.columns);

            for (int i = 0; i < m1.rows; i++)
            {
                for (int k = 0; k < m2.columns; k++)
                {
                    for (int j = 0; j < m2.rows; j++)
                    {
                        //UnityEngine.Debug.Log(i + " " + k + " " + j);
                        mat3.SetAt(i, k, mat3.GetAt(i, k) + m1.GetAt(i, j) * m2.GetAt(j, k));
                    }
                }
            }
            //UnityEngine.Debug.Log("Succes");
            return(mat3);
        }
        else
        {
            //UnityEngine.Debug.LogError("FAIL");
            return(mat2);
        }
    }
Exemple #3
0
 Matriz Activation(Matriz m)
 {
     for (int i = 0; i < m.rows; i++)
     {
         for (int j = 0; j < m.columns; j++)
         {
             //m.SetAt(i, j, MathL.Sigmoid(m.GetAt(i, j)));
             m.SetAt(i, j, (float)MathL.HyperbolicTangtent(m.GetAt(i, j)));
         }
     }
     return(m);
 }
Exemple #4
0
 void ActivationLast(Matriz m)
 {
     rotation     = (float)MathL.HyperbolicTangtent(m.GetAt(0, 0));
     acceleration = MathL.Sigmoid(m.GetAt(1, 0));
 }