Nhận dạng mẫu

Mạng thần kinh được sử dụng trong các ứng dụng như Nhận dạng khuôn mặt.

Các ứng dụng này sử dụng Nhận dạng mẫu .

Loại Phân loại này có thể được thực hiện với Perceptron .

Phân loại mẫu

Hãy tưởng tượng một đường eo biển (một đồ thị tuyến tính) trong một không gian với các điểm xy nằm rải rác.

Làm thế nào bạn có thể phân loại các điểm trên và dưới dòng?

Một perceptron có thể được đào tạo để nhận ra các điểm trên đường thẳng mà không cần biết công thức của đường thẳng.

Perceptron

Perceptron thường được sử dụng để phân loại dữ liệu thành hai phần.

Perceptron còn được gọi là Bộ phân loại nhị phân tuyến tính.


Cách lập trình Perceptron

Để tìm hiểu thêm về cách lập trình perceptron, chúng tôi sẽ tạo một chương trình JavaScript rất đơn giản sẽ:

  1. Tạo một máy vẽ đơn giản
  2. Tạo 500 điểm xy ngẫu nhiên
  3. Hiển thị các điểm xy
  4. Tạo một hàm dòng: f (x)
  5. Hiển thị dòng
  6. Tính toán các câu trả lời mong muốn
  7. 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