Esempio n. 1
0
        public void Train(bool[] pattern)
        {
            Matrix m2       = Matrix.CreateRowMatrix(BiPolarUtil.Bipolar2double(pattern));
            Matrix m1       = m2.Clone().Transpose();
            Matrix m3       = m1 * m2;
            Matrix identity = m3.Identity(IdentityMult.BEFORE);

            m3           -= identity;
            weightMatrix += m3;
        }
Esempio n. 2
0
        public bool[] Present(bool[] pattern)
        {
            bool[] output      = new bool[pattern.Length];
            Matrix inputMatrix = Matrix.CreateRowMatrix(BiPolarUtil.Bipolar2double(pattern));

            for (int col = 0; col < pattern.Length; col++)
            {
                Matrix columnMatrix = Matrix.CreateRowMatrix(weightMatrix.GetCol(col).ToArray());
                double dotProduct   = Matrix.Dot(inputMatrix.RowData()[0].ToArray(), columnMatrix.RowData()[0].ToArray());
                if (dotProduct > 0)
                {
                    output[col] = true;
                }
                else
                {
                    output[col] = false;
                }
            }
            return(output);
        }