title: How to train multiple inputs for Perceptron in C#?
body: <p>I recently just coded a perceptron that takes in an OR gate as it's value. However, currently my code can only train 1 point whereas I want it to train 4 point of the OR gate. Here's my attached code, I am still learning how to program so please excuse me for some of my errors.</p>
  
  <pre class="lang-c prettyprint-override"><code>using System;
  using ActivationFunction;
  namespace Perceptron
  {
      class Point
      {
  
  
          private double input1; //creates private field
          public double Input1 { get =&gt; input1; set =&gt; input1 = value; } //creates public property (important for encapsulation of data)
          private double input2;
          public double Input2 { get =&gt; input2; set =&gt; input2 = value; }
          private double desiredOutput;
          public double DesiredOutput { get =&gt; desiredOutput; set =&gt; desiredOutput = value; }
  
          public Point() /*Creates an empty constructor so that the object of the
                         class can be instantiated to refer variables*/
          {
  
          }
  
          public Point(int input1, int input2, int desiredOutput) //Takes in the inputs for the perceptron
          {
  
              this.input1 = input1;
              this.input2 = input2;
              this.desiredOutput = desiredOutput;
  
              Console.WriteLine("INPUT 1 =&gt; " + Input1);
              Console.WriteLine("INPUT 2 =&gt; " + Input2);
              Console.WriteLine("DESIRED OUTPUT =&gt; " + desiredOutput);
          }
      }
  
      class NeuralNetwork
      {
          readonly Point point = new Point(); //used for referring variables from point to class
  
          private double[] weights = new double[3];
  
          private double output; 
  
          private const double bias = 1; //creates constant bias
  
          private double error; 
  
          private const double learningRate = 0.25; //constant learningRate 
  
          public NeuralNetwork(Point point) //Might be unnecessary...
          {
              this.point = point;
          }
  
          public void RandomiseWeightsAndBias()
          {
              Random rand = new Random();
  
              for (int i = 0; i &lt; weights.Length; i++) //loops through the weights
              {
                  weights[i] = rand.NextDouble();
  
                  weights[i] -= 0.5; // expected range now -0.5 to +0.5
                  weights[i] *= 2; //expected range now -1 to 1
  
                  Console.WriteLine("STARTING SYNAPTIC WEIGHTS =&gt; " + weights[i]);
  
              }
  
              Console.WriteLine("BIAS IS =&gt; " + bias);
          }
  
          public double DotProductBias() //Sums up the inputs and weights together
          {
  
              return point.Input1 * weights[0] + point.Input2 * weights[1] + bias * weights[2];
          }
  
          public double ActivationFunction() //Applies activation function
          {
              DotProductBias();
              output = ActivationFunctions.StepActivation(DotProductBias()); //The Activation Function is in part of another class, there is a built in static function that takes in a static double as input
              return output;
          }
  
  
          public void CalculateError() //Calculate Error
          {
              error = point.DesiredOutput - output;
              Console.WriteLine("ERROR IS =&gt; " + error);
          }
  
          public void AdjustWeights() //Perform gradient descent
          {
  
              weights[0] += learningRate * weights[0] + error * point.Input1; //I know I can use for loops to make it more concise and clean but it works for now
              weights[1] += learningRate * weights[1] + error * point.Input2;
              weights[2] += learningRate * weights[2] + error * bias;
  
              for (int i = 0; i &lt; weights.Length; i++)
              {
                  Console.WriteLine("ADJUSTED WEIGHTS ARE =&gt; " + weights[i]);
              }
  
  
          }
  
          public void Train(int epochs) //Training or "backpropagating the weights"
          {
  
              for (int i = 0; i &lt; epochs; i++)
              {
                  AdjustWeights();
              }
          }
  
      }
  
      class Program
      {
  
          static void Main(string[] args)
          {
  
              var point = new Point(0, 1, 1);
  
              /*
              var point2 = new Point(0, 1, 0);
              var point3 = new Point(1, 0, 0);
              var point4 = new Point(1, 1, 1);
              */
  
              var neuralNetwork = new NeuralNetwork(point);
  
              neuralNetwork.RandomiseWeightsAndBias();
              neuralNetwork.ActivationFunction();
              neuralNetwork.CalculateError();
              neuralNetwork.Train(8);
  
              Console.WriteLine("THE FINAL OUTPUT IS " + neuralNetwork.ActivationFunction());
  
          }
      }
  
  }
  </code></pre>
  
  <p>Looking at the code, it's clear that I need to change the values of the constructors in the Point class, perhaps change the inputs to an array or a list? Please help!</p>