Update Weights in Linear Perceptron

Last updated on June 3, 2023 am

Update Weights in Linear Perceptron

Sometimes you just find that preparing the data and visualizing it takes more time than building an AI model.

Linear Perceptron

It took me quite a long time to figure out how the weights are updated in a simple perceptron model. Basically it follows the gradient descent procedure, but things in linear algebra format confused me for a while and I don’t know why so few people write it down explicitly.

It goes like this:

w_new = w_old + learning_rate * (y_true - y_predicted) * x

where

  • all of the parameters are vectors, except the learning rate.
  • x is the input vector
  • y_true is the true label of the input (either 1 or -1 for a binary classification problem)
  • y_predicted is the predicted label of the input (either 1 or -1 for a binary classification problem)

If it predicts a positive value as negative, w should be set higher and vice versa.

Some Quotes

Here are some intriguing quotes from Prof. Hung-yi Lee (李宏毅)’s lecture. What a charismatic man.

好,那到目前为止,我们讲了很多各式各样的模型,那我们现在还缺了一个东西,你知道缺什么东西吗?缺一个好名字。你知道这个外表啊是很重要的,一个死臭酸宅穿上西装以后就潮了起来;或者是织席贩履的,说他是汉左将军宜城亭侯中山靖王之后,也就潮了起来,对不对?所以我们的模型,也需要一个好名字。

Neuron 是什么?Neuron 就是神经元。人脑中就是有很多神经元,很多神经元串起来就是一个神经网路,跟你的脑是一样的。接下来你就可以到处骗麻瓜说,“看到没有,这个模型就是在模拟人们脑,知道吗?这就是在模拟人脑,这个就是人工智慧”,然后麻瓜就会吓得把钱掏出来。

但是啊,这个把戏在 80,90 年代的时候已经玩过了。Neural Network 不是什么新的技术,80,90 年代就已经用过了,当时已经把这个技术的名字搞到臭掉了。Neural Network 因为之前被吹捧得太过浮夸,所以后来大家对 Neural Network 这个名字都非常地感冒。它就像是个脏话一样,写在 paper 上面都注定害你的 paper 被拒绝。所以后来为了要重振 Neural Network 的雄风,所以怎么办呢?需要新的名字。怎么样新的名字呢?这边有很多的 Neuron,每一排 Neuron 我们就叫它一个 Layer,它们叫 Hidden Layer。有很多的 Hidden Layer 就叫做 Deep,这整套技术就叫做 Deep Learning。

References

  1. 【機器學習2021】預測本頻道觀看人數 (上) - 機器學習基本概念簡介 - YouTube
  2. 【機器學習2021】預測本頻道觀看人數 (下) - 深度學習基本概念簡介 - YouTube
  3. Hung-yi Lee (李宏毅)
  4. cs188-fa22-note20.pdf
  5. CS 188 Fall 2022 | Introduction to Artificial Intelligence at UC Berkeley
  6. Lecture 4 - Perceptron & Generalized Linear Model | Stanford CS229: Machine Learning (Autumn 2018) - YouTube
  7. CS229: Machine Learning
  8. Perceptron Learning Algorithm 感知器算法 - 神经网络基础 - wty’s blog
  9. 感知机原理小结 - 刘建平Pinard - 博客园

Update Weights in Linear Perceptron
https://lingkang.dev/2023/05/12/perceptron/
Author
Lingkang
Posted on
May 12, 2023
Licensed under