What is a Perceptron?

nahid
Udacity PyTorch Challengers
4 min readDec 27, 2018

--

So, let’s say you work at a medical laboratory and you’ve been given the task to build an artificially intelligent solution that’s capable of determining if a patient has cancer or not based on documented data that you already have.

In technical terms this can be understood as: A supervised learning problem that requires an AI model to classify the inputted case into one of two (binary) classes or categories, i.e. does this patient have cancer or not?

The AI solution/model here will be a Perceptron.

What does a Perceptron look like?

Truth be told a perceptron and almost all other AI models are a bunch of mathematical equations in code but it is common practice to depict (in examples, animations, drawings etc) these AI models to illustrate their functioning. A perceptron is commonly compared to the neurons in the brain.

Source: https://appliedgo.net/perceptron/

The neuron takes signals/inputs via our senses through the dendrites and based on that information the cell body comes out with the output(s).

Similarly, a perceptron takes in inputs supplied by us, performs a summation of these inputs and thus provides the output.

A Closer Look:

As mentioned above, what a perceptron basically does is classify or create a distinction in the data provided. If we were to view our data as a plot on a graph, the perceptron’s job is to come up with a linear line to sensibly classify the data. At this point it is important to remember the general equation of a straight line:

Equation of a straight line

Now, let’s dive into what a perceptron is made of:

Source: https://blog.knoldus.com/introduction-to-perceptron-neural-network/

A perceptron is made up of the following: the input layer, corresponding weights, weighted sum, an activation function and lastly the output.

Input layer: This layer corresponds to the data we are feeding into our perceptron and the bias. For now, think of each input x1, x2 etc as numbers and also note that a perceptron is not limited a specific number of inputs. Each input will here on out be referred to an input node or simply, node. And the bias here represents the constant c (from the equation of a straight line seen above), in the straight line that our perceptron will be forming and using for classification. The bias in most perceptron models is taken as 1, this is will be made clear in the next point.

Weights: Each node of our perceptron will have an associated weight attached to it which is basically a number that describes that specific node’s importance or relevance to the equation. It is important to note that since the bias is taken as 1, the corresponding weight of the bias will be the constant c of our straight line equation (as seen above).

Weighted Sum: The net sum of the product between each node and its weight is calculated here, this important for what comes next.

Now, we need to sit back and remind ourselves of what the output of a perceptron should be. Up to this point we’ve stated that a perceptron is meant to classify, differentiate, separate, say yes or no, i.e. provide the output to our binary scenario. Thus, we will need an extra function that is capable of making sense of the weighted sum and thus classifying our given case.

Activation Function: Here we will use a step function in order to make sense of our weighted sum. A step function outputs 1 for any input that’s equal to or greater than 0 and outputs 0 for any input that’s less than 0. In other words, the output of a perceptron is a boolean output.

And based on the data we’ve had prior to this solution we will be able to make sense of what the 1s and 0s represent.

In conclusion, that brings us to our initial case study of cancer data. Based on this data, our perceptron will now be able to find an imaginary straight line that classifies/separates the data to correspond to cancerous and non-cancerous patients. Now armed with this knowledge, it is capable of predicting to a fairly comfortable extent the cancer test results of an unknown patient.

Other uses cases of a perceptron

Due to the perceptron’s nature to be able differentiate one output class/case from another by giving boolean result, they can also be used to implement logic gates like AND, OR or even XOR gates!

You can find more information on this here.

Suggested reads:

  1. What the hell is a perceptron?
  2. Perceptrons — the most basic form of a neural network

That brings me to do end of my first article on Perceptrons! If you liked this then please follow and leave a comment on how you think the next article could be better!

Next up — Multilayer Perceptrons! Stay tuned!

--

--