Skip to content

Latest commit

 

History

History
100 lines (59 loc) · 5.81 KB

File metadata and controls

100 lines (59 loc) · 5.81 KB

Introduction to Neural Networks: Perceptron

One of di first try wey dem do to create somtin wey resemble modern neural network na Frank Rosenblatt from Cornell Aeronautical Laboratory for 1957. E be hardware wey dem call "Mark-1", wey dem design to sabi primitive geometric shapes like triangle, square and circle.

Frank Rosenblatt The Mark 1 Perceptron

Images from Wikipedia

Di input image na 20x20 photocell array, so di neural network get 400 inputs and one binary output. Di simple network get one neuron, wey dem dey call threshold logic unit. Di neural network weights dey act like potentiometer wey dem go need adjust manually during di training phase.

✅ Potentiometer na device wey person fit use to adjust di resistance for circuit.

Di New York Times talk about perceptron for dat time: di embryo of one electronic computer wey [di Navy] dey expect say e go fit waka, talk, see, write, reproduce itself and sabi say e dey exist.

Perceptron Model

Make we assume say we get N features for our model, di input vector go be vector wey get size N. Perceptron na binary classification model, e mean say e fit separate two classes of input data. We go assume say for each input vector x, di output of our perceptron go be either +1 or -1, depending on di class. Di output go dey calculate with di formula:

y(x) = f(wTx)

where f na step activation function

Training the Perceptron

To train perceptron, we need to find weights vector w wey go classify most of di values correct, e mean say e go give di smallest error. Dis error E na wetin dem dey define with perceptron criterion like dis:

E(w) = -∑wTxiti

where:

  • di sum na for di training data points i wey dey give wrong classification
  • xi na di input data, and ti na either -1 or +1 for negative and positive examples.

Dis criteria na function of weights w, and we need to minimize am. Most times, dem dey use method wey dem dey call gradient descent, wey we go start with some initial weights w(0), and then for each step we go update di weights with di formula:

w(t+1) = w(t) - η∇E(w)

Here η na wetin dem dey call learning rate, and ∇E(w) na di gradient of E. After we calculate di gradient, we go get:

w(t+1) = w(t) + ∑ηxiti

Di algorithm for Python go look like dis:

def train(positive_examples, negative_examples, num_iterations = 100, eta = 1):

    weights = [0,0,0] # Initialize weights (almost randomly :)
        
    for i in range(num_iterations):
        pos = random.choice(positive_examples)
        neg = random.choice(negative_examples)

        z = np.dot(pos, weights) # compute perceptron output
        if z < 0: # positive example classified as negative
            weights = weights + eta*weights.shape

        z  = np.dot(neg, weights)
        if z >= 0: # negative example classified as positive
            weights = weights - eta*weights.shape

    return weights

Conclusion

For dis lesson, you don learn about perceptron, wey be binary classification model, and how to train am by using weights vector.

🚀 Challenge

If you wan try build your own perceptron, try dis lab for Microsoft Learn wey dey use Azure ML designer.

Review & Self Study

To see how we fit use perceptron solve toy problem and real-life problems, and to continue di learning - go Perceptron notebook.

Here na one interesting article about perceptrons too.

For dis lesson, we don implement perceptron for binary classification task, and we don use am to classify between two handwritten digits. For dis lab, dem dey ask you to solve di problem of digit classification completely, e mean say make you determine which digit dey most likely correspond to di given image.


Disclaimer:
Dis docu don use AI translation service Co-op Translator take translate am. Even though we dey try make e accurate, abeg sabi say automated translations fit get mistake or no correct well. Di original docu for di language wey dem write am first na di main correct one. For important information, e good make una use professional human translation. We no go fit take blame for any misunderstanding or wrong interpretation wey fit happen because of dis translation.