web analytics

Single layer perceptron learning algorithm program w/ flowchart & Code in C++

Single layer perceptron is the first proposed neural model created. The content of the local memory of the neuron consists of a vector of weights. The computation of a single layer perceptron is performed over the calculation of sum of the input vector each with the value multiplied by corresponding element of vector of the weights. The value which is displayed in the output will be the input of an activation function.

Algorithm:

  1. Initialize all weights and threshold and values.
  2. Get the weighted sum of one input.
  3. Compare the weighted sum with the threshold and set value to output.
    1. If the input is of class A
      1. If the desired output mismatches with the output
        1. Decrease those weights which have corresponding 1 in the input
      2. Else Take the next input and go to Step 2
    2. Else If the desired output mismatches with the output
      1. Increase those weights which have corresponding 1 in the input
    3. Else Take the next input and go to Step 2
  4. While all weights has been set, take input from the user.
  5. Get the weighted sum for this input
  6. Compare the weighted sum with the threshold
    1. If weighted sum is less then the threshold
      1. input is from Class A
    2. Else input is from Class B

Flowchart of the Program:

Part 01:

Click on image to see enlarged view

Part 02:

Source Code:

You can run the code using the RUN button at the end of the code

Link to source code https://www.onlinegdb.com/

Output:

single-layer-perceptron-learning-algorithm-run-output
It was an assignment when I was having the course Theory of Computation. I don’t think this blog post has simplified the matter at all. However if it helps you anyway, I will be glad to know that.
Please follow and like us:
Pin Share

14 thoughts on “Single layer perceptron learning algorithm program w/ flowchart & Code in C++”

  1. Great work done… It is a bit late… but keep it up… don't let others get to you.. Your post is good and i have benefited from it… Thanx…

  2. best solution of the problem………
    also the flow chart is the good idea to understand the newbies…

  3. Yes I can, but in VB.NET 2010 and also, I must have to be described about the Input and Output, I mean, what will be your input and what you will want as the output.

Comments are closed.

RSS
Follow by Email
Scroll to Top