thoughts @thoughts

Introduction to AI: What is a perceptron?

A perceptron is the simplest subtype of AI.

The perceptron works like so ^

We have 3 inputs x, 3 coresponding weights w, and the output y.

Let’s say the inputs are: 1, 0, 1

And the weights are: 0.9, 0.14, 0.15

Weights are basically how important their inputs are

We now add all inputs multiplied by their weights

And the threshold can be calculated by (numberofinputs * numberofinputs) / 10, so in this case: it’s 0.9

Then, the activation function, which we set the y to: if the sum is over the threshold, we return 1, otherwise we return 0,

and that is a perceptron

In javascript:

var x = [1, 0, 0]
var w = []
// random weights
for (let i in x) w.push(Math.random())

// sum
var y = 0;
for (let i in x) y = y + x[i] * w[i]

// threshold
var threshold = (x.length * x.length) / 10

// activation
y = y > threshold ? 1 : 0
Dec 20, 2022, 8:33 AM
2

comments