Understanding Perceptron Learning Algorithm in Neural Networks

Slide Note
Embed
Share

Explore the concept of Perceptron Learning Algorithm and its application in Artificial Neural Networks. Learn about nodes, weights, thresholds, training techniques, and adjustments needed for accurate predictions.


Uploaded on Sep 11, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Perceptron Learning David Kauchak CS51A Spring 2019

  2. Artificial Neural Networks Node (Neuron) Edge (synapses)

  3. Node A Node B Weight w (neuron) (neuron) W is the strength of signal sent between A and B. If A fires and w is positive, then A stimulatesB. If A fires and w is negative, then A inhibitsB.

  4. A Single Neuron/Perceptron Input x1 Each input contributes: xi * wi Weight w1 Weight w2 Input x2 g(in) Output y threshold function Input x3 Weight w3 i in = wi xi Weight w4 Input x4

  5. Training neural networks x1 x2 x3 x1 and x2 1 Input x1 w1 = ? w2 = ? Input x2 0 0 0 Output y T = ? 0 1 0 0 Input x3 w3 = ? 1 0 0 1 1 1 0 0 1. start with some initial weights and thresholds 2. show examples repeatedly to NN 3. update weights/thresholds by comparing NN output to actual output 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0

  6. Perceptron learning algorithm repeat until you get all examples right: - for each training example: - calculate current prediction on example - if wrong: - update weights and threshold towards getting this example correct

  7. Perceptron learning 1 1 predicted ? -1 1 actual 1 0 1 Threshold of 1 0.5 1

  8. Perceptron learning Weighted sum is 0.5, which is not equal or larger than the threshold 1 1 predicted 0 -1 1 actual 1 0 1 Threshold of 1 0.5 1 What could we adjust to make it right?

  9. Perceptron learning 1 1 predicted 0 -1 1 actual 1 0 1 Threshold of 1 0.5 1 This weight doesn t matter, so don t change

  10. Perceptron learning 1 1 predicted 0 -1 1 actual 1 0 1 Threshold of 1 0.5 1 Could increase any of these weights

  11. Perceptron learning 1 1 predicted 0 -1 1 actual 1 0 1 Threshold of 1 0.5 1 Could decrease the threshold

  12. Perceptron update rule - if wrong: - update weights and threshold towards getting this example correct - if wrong: wi = wi + wi wi = * (actual - predicted) * xi

  13. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi What does this do in this case?

  14. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi causes us to increase the weights!

  15. Perceptron learning predicted 1 actual 0 Threshold of 1 wi = wi + wi wi = * (actual - predicted) * xi What if predicted = 1 and actual = 0?

  16. Perceptron learning predicted 1 actual 0 Threshold of 1 wi = wi + wi wi = * (actual - predicted) * xi We re over the threshold, so want to decrease weights: actual - predicted = -1

  17. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi What does this do?

  18. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi Only adjust those weights that actually contributed!

  19. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi What does this do?

  20. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi learning rate : value between 0 and 1 (e.g 0.1) adjusts how abrupt the changes are to the model

  21. Perceptron learning 1 1 -1 1 predicted 0 1 0 actual 1 Threshold of 1 0.5 1 wi = wi + wi wi = * (actual - predicted) * xi What about the threshold?

  22. Input x1 Weight w1 3 Weight w2 t 1 if Input x2 wixi Output y i=1 Input x3 Weight w3 Threshold of t 3 Input x1 Weight w1 1 if w4+ 0 wixi Weight w2 i=1 Input x2 Output y Input x3 Weight w3 Threshold of 0 1

  23. Input x1 Weight w1 3 Weight w2 t 1 if Input x2 wixi Output y i=1 Input x3 Weight w3 Threshold of t 3 Input x1 Weight w1 1 if w4+ 0 wixi Weight w2 i=1 Input x2 Output y Input x3 Weight w3 Threshold of 0 1 equivalent when w4 = -t

  24. Perceptron learning algorithm initialize weights of the model randomly repeat until you get all examples right: - for each training example (in a random order): - calculate current prediction on the example - if wrong: wi = wi + * (actual - predicted) * xi

  25. = 0.1 x1 x2 x1 and x2 0 0 0 initialize with random weights 0 1 0 1 0 0 1 1 1 W1 Input x1 W2 Output y Input x2 W3 1

  26. = 0.1 x1 x2 x1 and x2 0 0 0 0 1 0 1 0 0 1 1 1 W1 = 0.2 Input x1 W2 = 0.5 Output y Input x2 1 W3 = 0.1

  27. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.2 1 W2 = 0.5 Output y 0 1 W3 = 0.1 Right or wrong?

  28. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.2 1 sum = 0.3: output 1 W2 = 0.5 Output y 0 1 W3 = 0.1 Wrong

  29. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.2 1 sum = 0.3: output 1 W2 = 0.5 Output y 0 1 W3 = 0.1 new weights?

  30. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 sum = 0.3: output 1 W2 = 0.5 Output y 0 1 W3 = 0.0 decrease (0-1=-1) all non-zero xi by 0.1

  31. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 W2 = 0.5 Output y 1 1 W3 = 0.0 Right or wrong?

  32. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 sum = 0.6: output 1 W2 = 0.5 Output y 0 1 W3 = 0.0 Right. No update!

  33. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 W2 = 0.5 Output y 1 1 W3 = 0.0 Right or wrong?

  34. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.5: output 1 W2 = 0.5 Output y 1 1 W3 = 0.0 Wrong

  35. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.5: output 1 W2 = 0.5 Output y 1 1 W3 = 0.0 new weights?

  36. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.5: output 1 W2 = 0.4 Output y 1 1 W3 = -0.1 decrease (0-1=-1) all non-zero xi by 0.1

  37. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 W2 = 0.4 Output y 0 1 W3 = -0.1 Right or wrong?

  38. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = -0.1: output 0 W2 = 0.4 Output y 0 1 W3 = -0.1 Right. No update!

  39. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 W2 = 0.4 Output y 1 1 W3 = -0.1 Right or wrong?

  40. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.3: output 1 W2 = 0.4 Output y 1 1 W3 = -0.1 Wrong

  41. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.3: output 1 W2 = 0.3 Output y 1 1 W3 = -0.2 decrease (0-1=-1) all non-zero xi by 0.1

  42. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 sum = 0.2: output 1 W2 = 0.3 Output y 1 1 W3 = -0.2 Right. No update!

  43. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = -0.2: output 0 W2 = 0.3 Output y 0 1 W3 = -0.2 Right. No update!

  44. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 sum = -0.1: output 0 W2 = 0.3 Output y 0 1 W3 = -0.2 Right. No update!

  45. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 W2 = 0.3 Output y 0 1 W3 = -0.2 Are they all right?

  46. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.1: output 1 W2 = 0.3 Output y 1 1 W3 = -0.2 Wrong

  47. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.1: output 1 W2 = 0.2 Output y 1 1 W3 = -0.3 decrease (0-1=-1) all non-zero xi by 0.1

  48. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 0 sum = 0.1: output 1 W2 = 0.2 Output y 1 1 W3 = -0.3 Are they all right?

  49. = 0.1 x1 x2 x1 and x2 0 0 0 if wrong: 0 1 0 1 0 0 wi = wi + * (actual - predicted) * xi 1 1 1 W1 = 0.1 1 W2 = 0.2 Output y 1 1 W3 = -0.3 We ve learned AND!

  50. Perceptron learning A few missing details, but not much more than this Keeps adjusting weights as long as it makes mistakes If the training data is linearly separable the perceptron learning algorithm is guaranteed to converge to the correct solution (where it gets all examples right)

Related


More Related Content