パターン認識
ニューラルネットワークは、顔認識などのアプリケーションで使用されます。
これらのアプリケーションはパターン認識を使用します。
このタイプの分類は、パーセプトロンを使用して実行できます。
パターン分類
xy点が散在している空間の直線(線形グラフ)を想像してみてください。
線の上下のポイントをどのように分類できますか?
パーセプトロンは、線の式を知らなくても、線上の点を認識するようにトレーニングできます。
パーセプトロンは、データを2つの部分に分類するためによく使用されます。
パーセプトロンは、線形二項分類器としても知られています。
パーセプトロンをプログラムする方法
パーセプトロンをプログラムする方法の詳細を学ぶために、次のような非常に単純なJavaScriptプログラムを作成します。
- 簡単なプロッタを作成する
- 500個のランダムなxyポイントを作成します
- xyポイントを表示します
- ライン関数を作成します:f(x)
- 行を表示する
- 希望する答えを計算する
- Display the desired answers
Create a Simple Plotter
Use the simple plotter object described in the AI Plotter Chapter.
Example
const plotter = new XYPlotter("myCanvas");
plotter.transformXY();
const xMax = plotter.xMax;
const yMax = plotter.yMax;
const xMin = plotter.xMin;
const yMin = plotter.yMin;
Create Random X Y Points
Create as many xy points as wanted.
Let the x values be random, between 0 and maximum.
Let the y values be random, between 0 and maximum.
Display the points in the plotter:
Example
const numPoints = 500;
const xPoints = [];
const yPoints = [];
for (let i = 0; i < numPoints; i++) {
xPoints[i] = Math.random() * xMax;
yPoints[i] = Math.random() * yMax;
}
Create a Line Function
Display the line in the plotter:
Example
function f(x) {
return x * 1.2 + 50;
}
Compute Desired Answers
Compute the desired answers based on the line function:
y = x * 1.2 + 50.
The desired answer is 1 if y is over the line and 0 if y is under the line.
Store the desired answers in an array (desired[]).
Example
let desired = [];
for (let i = 0; i < numPoints; i++) {
desired[i] = 0;
if (yPoints[i] > f(xPoints[i])) {desired[i] = 1;}
}
Display the Desired Answers
For each point, if desired[i] = 1 display a blue point, else display a black point.
Example
for (let i = 0; i < numPoints; i++) {
let color = "blue";
if (desired[i]) color = "black";
plotter.plotPoint(xPoints[i], yPoints[i], color);
}
How to Train a Perceptron
In the next chapters, you will learn more about how to Train the Perceptron