Guest User

Untitled

a guest
Jun 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1.             Console.WriteLine("\nXOR - ANN");
  2.             Console.WriteLine("0 , 0 = " + XOR(0, 0));
  3.             Console.WriteLine("0 , 1 = " + XOR(0, 1));
  4.             Console.WriteLine("1 , 0 = " + XOR(1, 0));
  5.             Console.WriteLine("1 , 1 = " + XOR(1, 1));
  6.  
  7. static bool XOR(float i1, float i2)
  8.         {
  9.             bool isTrue = false;
  10.  
  11.             float weight = 1f;
  12.  
  13.             float sumdInput = (i1 *= weight) + (i2 *= weight);
  14.  
  15.             float sumdValue = 0;
  16.  
  17.             float[,] tHidden = new float[,] { {1.5f, 0.5f},{-1.0f,1.0f} };
  18.             float[] tOut = new float[] { 0.5f };
  19.  
  20.             for (int i = 0; i < tHidden.GetLength(0); i++)
  21.             {
  22.                 if (sumdInput > tHidden[0, i])
  23.                     sumdValue += tHidden[1, i];
  24.             }
  25.  
  26.             if (sumdValue > tOut[0])
  27.                 isTrue = true;
  28.  
  29.             return isTrue;
  30.         }
Add Comment
Please, Sign In to add comment