Video
Đăng bởi Ban biên tập OpenER ·
Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
[INTERPOSING VOICES] PROFESSOR: Hi, everyone.
[NHIỀU NGƯỜI NÓI CÙNG LÚC] GIÁO SƯ: Chào các bạn.
Welcome to lecture 21 of CS 188. Today we'll cover perceptrons and logistic regression. Couple of announcements.
Chào mừng đến với bài giảng số 21 của CS 188. Hôm nay chúng ta sẽ học về perceptron và hồi quy logistic. Có vài thông báo.
Your project four is due on Friday at 4:00 PM. Your homework 10 will be released soon.
Project bốn hạn nộp là 4 giờ chiều thứ Sáu. Bài tập về nhà 10 sẽ sớm được đăng.
Next Monday is a holiday so your homework is going to be due on Tuesday exceptionally rather than Monday. And then your midterm two is coming up. That's on Thursday.
Thứ Hai tuần sau là ngày nghỉ, nên bài tập về nhà ngoại lệ sẽ hạn nộp vào thứ Ba chứ không phải thứ Hai. Rồi sắp tới là midterm hai. Vào thứ Năm.
So please prepare for that. Any questions about logistics? Yes.
Các bạn nhớ chuẩn bị nhé. Có câu hỏi nào về các vấn đề này không? Mời bạn.
STUDENT
What materials are covered for — PROFESSOR: What materials will be covered for midterm two?
Kiến thức nào sẽ được thi ạ — GIÁO SƯ: Midterm hai sẽ thi những phần nào à?
It will be everything from the very beginning of the semester all the way through naive Bayes, which was last lecture and the current homework.
Là mọi thứ từ đầu học kỳ cho đến hết naive Bayes, tức là bài giảng trước và bài tập về nhà hiện tại.
What we cover today and today onwards will be part of the final but not part of midterm two.
Những gì học từ hôm nay trở đi sẽ thuộc phần thi cuối kỳ chứ không thuộc midterm hai.
And midterm two will have more emphasis on materials covered after midterm one than before but it'll be a mix of both materials.
Midterm hai sẽ nhấn mạnh hơn vào phần học sau midterm một so với trước đó, nhưng sẽ là sự kết hợp cả hai.
STUDENT
How much is it?
Nhấn mạnh bao nhiêu ạ?
PROFESSOR
It's hard to know ahead of time. We just tried to put more emphasis on it. Then some questions come out better than others, and that affects which questions end up on the exam.
Khó biết trước được. Tụi thầy chỉ cố nhấn mạnh phần đó hơn. Có câu hỏi hay hơn những câu khác, và điều đó ảnh hưởng đến câu nào vào đề.
But the kind of mindset ahead of time is more emphasis on materials that came later. But sometimes it'll be a mix.
Nhưng định hướng ban đầu là nhấn mạnh hơn vào phần học sau. Nhưng đôi khi sẽ là kết hợp.
So it'll be about materials that came later and earlier all in one question. And you need to understand both to be able to solve those kind of questions.
Tức là một câu có thể gồm cả phần học sau và phần học trước trong cùng một câu hỏi. Và các bạn cần hiểu cả hai để giải những câu như vậy.
Yes.
Mời bạn.
STUDENT
Will there be a review session?
Sẽ có buổi ôn tập không ạ?
PROFESSOR
Yes. So we'll release a midterm two prep page probably on Thursday evening.
Có. Thầy sẽ đăng trang chuẩn bị midterm hai, chắc vào tối thứ Năm.
There will be review sessions in the first half of next week, and there will be a practice midterm two that we'll probably do on Monday or Tuesday, a couple of days before the midterm.
Sẽ có các buổi ôn tập trong nửa đầu tuần sau, và sẽ có một đề midterm hai thi thử chắc làm vào thứ Hai hoặc thứ Ba, trước midterm vài ngày.
Similar to how midterm one was.
Giống như midterm một.
So today we'll look at perceptrons and logistic regression. And before we do that, let's take a quick step back to what you covered last lecture, as well as the lectures before that.
Hôm nay chúng ta sẽ xem perceptron và hồi quy logistic. Trước đó, ta hãy lùi lại một chút xem lại bài giảng trước và những bài trước nữa.
So the recent five, six, seven, eight lectures was about probabilistic models.
Năm, sáu, bảy, tám bài giảng gần đây nói về các mô hình xác suất.
And if we train a probabilistic model over all variables that we might care about, we can then reuse that probabilistic model to make decisions for specific queries.
Nếu huấn luyện một mô hình xác suất trên mọi biến mà ta quan tâm, thì ta có thể dùng lại mô hình đó để ra quyết định cho các truy vấn cụ thể.
For example, what's the probability of a class label y given some feature values f1 through fn? And that was one way you could reuse those models. And that's what we saw with naive Bayes.
Ví dụ, xác suất của nhãn lớp y là bao nhiêu khi biết các giá trị đặc trưng f1 đến fn? Đó là một cách để dùng lại các mô hình ấy. Và đó là điều ta thấy với naive Bayes.
For a specific type of Bayes net, you can use it to answer conditional queries about a class label.
Với một loại mạng Bayes cụ thể, ta dùng nó để trả lời các truy vấn có điều kiện về nhãn lớp.
Today we're going to look at, again, solving that kind of problem, where we have a set of features and we want to output the decision on what class might be represented by those features.
Hôm nay ta lại xét bài toán tương tự: có một tập đặc trưng và muốn đưa ra quyết định xem các đặc trưng đó biểu diễn lớp nào.
But we're not going to learn a full probabilistic model.
Nhưng ta sẽ không học một mô hình xác suất đầy đủ.
We're going to focus on just the decision of going from features to what the class label might be and ignore learning a full probabilistic model, which has some pros and cons.
Ta chỉ tập trung vào quyết định đi từ đặc trưng đến nhãn lớp, và bỏ qua việc học mô hình xác suất đầy đủ, việc này có ưu và nhược điểm.
If you want a full probabilistic model you're not going to get it with the methods from today.
Nếu bạn muốn một mô hình xác suất đầy đủ thì các phương pháp hôm nay sẽ không cho bạn điều đó.
But if all you care about is that decision, today's method will zone in more on the particulars of that decision. So what we'll look at is something called linear classifiers.
Nhưng nếu chỉ quan tâm đến quyết định đó, phương pháp hôm nay sẽ tập trung sâu hơn vào chi tiết của quyết định ấy. Thứ ta sẽ xem là bộ phân loại tuyến tính.
We'll have input — for example, email, like you've seen as a running example in previous lecture. Then the email gets turned into a feature vector. They'll still do the same thing.
Đầu vào, ví dụ là email, như ví dụ xuyên suốt ở bài giảng trước. Email được chuyển thành một vectơ đặc trưng. Vẫn làm như vậy.
In this case, the feature vector has a account of how often the word "free" occurs, how often your name occurs, how often a misspelling occurs, whether it's from a friend or not, and so forth.
Ở đây, vectơ đặc trưng đếm số lần từ "free" xuất hiện, số lần tên bạn xuất hiện, số lỗi chính tả, có phải từ bạn bè hay không, v.v.
The result of that is a real vector that is what we use to then make a decision from.
Kết quả là một vectơ thực mà ta dùng để đưa ra quyết định.
And then it might be spam or ham depending on whether we like this email or not.
Và kết quả có thể là spam hoặc ham tùy việc ta có thích email này hay không.
What we'll focus on today is this part over here — how to go from the feature vectors to a decision of what the class label might be.
Hôm nay ta tập trung vào phần này ở đây: cách đi từ vectơ đặc trưng đến quyết định nhãn lớp.
This part is very important too, going from x to f of x. Traditionally, it requires a lot of art in that you think carefully about what might be a good way to characterize text.
Phần này cũng rất quan trọng, đi từ x đến f của x. Theo truyền thống, nó đòi hỏi nhiều kỹ năng nghệ thuật, vì bạn phải suy nghĩ kỹ đâu là cách hay để mô tả văn bản.
Maybe occurrence of words. Maybe some words should be considered synonyms and then you count them together.
Có thể là sự xuất hiện của các từ. Có thể một số từ nên coi là từ đồng nghĩa rồi đếm gộp lại.
Maybe you should have some special things, like does it come from a friend as a feature and so forth. Those are an art to figure out. That's still sometimes how it's done.
Có thể nên thêm vài đặc trưng đặc biệt, như email có đến từ bạn bè không, v.v. Những thứ đó cần nhiều khéo léo để tìm ra. Đôi khi vẫn làm như vậy.
What we'll also see in the next next lecture is how to do this transition from x to f of x in a way that it's also learned.
Bài giảng sau nữa ta cũng sẽ thấy cách làm bước chuyển từ x sang f của x sao cho nó cũng được học.
But for now we'll assume f of x is available and go from f of x to y. Or it could be images. Input is an image.
Nhưng bây giờ ta giả sử đã có f của x và đi từ f của x đến y. Hoặc có thể là hình ảnh. Đầu vào là một hình ảnh.
That image gets turned into a feature vector that represents the image. In this case, the feature vector is a bunch of digits here.
Hình ảnh đó được chuyển thành vectơ đặc trưng biểu diễn hình ảnh. Ở đây, vectơ đặc trưng là một dãy chữ số.
Is there a pixel value that's on or off at each location? So 1 0 values. You could also use grayscale.
Mỗi vị trí có giá trị pixel bật hay tắt? Tức là các giá trị 1 0. Bạn cũng có thể dùng thang xám.
If it was a grayscale image, it would be a number between 0 and 1 maybe, or maybe sometimes from 0 to 255 if you have byte representation of images.
Nếu là ảnh xám thì nó sẽ là một số từ 0 đến 1, hoặc đôi khi từ 0 đến 255 nếu bạn dùng biểu diễn ảnh theo byte.
And then you might have more advanced features, like counting the number of loops in an image, and make that one of your features.
Rồi bạn có thể có các đặc trưng nâng cao hơn, như đếm số vòng khép kín trong ảnh, và đưa nó vào làm một đặc trưng.
And again, today is all about going from once you have those feature vectors to making a decision of what's in the image. And in the future, we'll look at this part.
Một lần nữa, hôm nay chủ yếu nói về việc từ khi đã có các vectơ đặc trưng đó đến việc đưa ra quyết định về thứ có trong ảnh. Còn phần này thì sau này ta sẽ xem.
Today's approach will be somewhat inspired by biology and how the brain works.
Cách tiếp cận hôm nay phần nào lấy cảm hứng từ sinh học và cách bộ não hoạt động.
Now, nobody really knows how the brain works so don't take this too seriously, but it's a loose inspiration of roughly some ideas of how the brain might work that we're going to use here.
Thực ra chẳng ai biết chính xác não hoạt động ra sao, nên đừng coi quá nghiêm trọng, đây chỉ là nguồn cảm hứng lỏng lẻo từ vài ý tưởng về cách não có thể hoạt động mà ta sẽ dùng ở đây.
So your brain consists of a bunch of neurons. Maybe, if you're pretty lucky, you have 100 billion neurons or something. And we're going to zone in on one of those neurons.
Não bạn gồm rất nhiều nơ-ron. Nếu khá may mắn thì có lẽ bạn có khoảng 100 tỷ nơ-ron. Và ta sẽ tập trung vào một nơ-ron trong số đó.
So this is just one of them out of, if it was a human, about 100 billion. So you have a neuron here. What does a neuron do? Well, it has a bunch of inputs.
Đây chỉ là một trong, nếu là con người, khoảng 100 tỷ nơ-ron. Vậy ta có một nơ-ron ở đây. Nơ-ron làm gì? Nó có nhiều đầu vào.
Stuff comes in here, here, here. They're called dendrites. That's where the inputs come in.
Tín hiệu đi vào chỗ này, chỗ này, chỗ này. Chúng gọi là các sợi nhánh (dendrite). Đó là nơi các đầu vào đi vào.
This could be coming maybe from your retina, where photons hit your eye, or it could be coming from other neurons sitting in another part of your brain that send signals over.
Có thể nó đến từ võng mạc, nơi các photon chạm vào mắt, hoặc đến từ các nơ-ron khác nằm ở một vùng khác của não gửi tín hiệu sang.
These signals come in. Then the nucleus here, the core of the neuron, based on what comes in, in some sense makes a decision.
Các tín hiệu này đi vào. Rồi nhân tế bào ở đây, lõi của nơ-ron, dựa trên những gì đi vào, theo nghĩa nào đó sẽ đưa ra quyết định.
It decides whether or not it's going to send out a signal over the output channel, which is called the axon.
Nó quyết định có gửi tín hiệu hay không qua kênh đầu ra, gọi là sợi trục (axon).
And the axon will then branch out and go reach many other neurons where this will become essentially the input to other neurons that come later.
Sợi trục sau đó sẽ phân nhánh và tới nhiều nơ-ron khác, nơi nó về cơ bản trở thành đầu vào của các nơ-ron phía sau.
We're not going to worry about the network of neurons for now. We're just going to worry about one of these.
Tạm thời ta chưa lo về mạng các nơ-ron. Ta chỉ quan tâm một nơ-ron thôi.
And so we're going to have maybe you can think of it as f1 coming in here, f2 coming in here, feature 3 coming in here, and feature n coming in here.
Vậy ta có thể coi như f1 vào đây, f2 vào đây, đặc trưng 3 vào đây, và đặc trưng n vào đây.
And then here we have a decision y that's coming out. Representing as a circuit diagram you have, essentially, a bunch of inputs that are wires.
Và ở đây ta có quyết định y đi ra. Biểu diễn bằng sơ đồ mạch thì về cơ bản ta có nhiều đầu vào là các dây dẫn.
Those wires could have a high signal or low signal. If they're very active they might influence more what comes out on the other side.
Các dây này có thể có tín hiệu cao hoặc thấp. Nếu chúng hoạt động mạnh thì có thể ảnh hưởng nhiều hơn đến đầu ra ở phía bên kia.
And then there will be weightings here — see the little weights here — that corresponds to the strength of the connections. With some neurons you'll be more strongly connected than with other ones.
Và sẽ có các trọng số ở đây, thấy mấy trọng số nhỏ này không, tương ứng với độ mạnh của các kết nối. Với một số nơ-ron, bạn kết nối mạnh hơn so với những nơ-ron khác.
Stronger connections will mean that you pay more attention to what's coming from that input.
Kết nối mạnh hơn nghĩa là bạn chú ý nhiều hơn đến những gì đến từ đầu vào đó.
And then somehow the combination of inputs is resulting in a output signal, which would, in our case, be a class label. So the inputs are the feature values.
Và rồi bằng cách nào đó, sự kết hợp các đầu vào tạo ra một tín hiệu đầu ra, mà trong trường hợp của ta là nhãn lớp. Vậy đầu vào là các giá trị đặc trưng.
Each feature has a weight, and the sum is the activation. So take a weighted sum of feature values. That's the activation, and we feed that out. Let's put that in mathematics.
Mỗi đặc trưng có một trọng số, và tổng là độ kích hoạt (activation). Tức là lấy tổng có trọng số của các giá trị đặc trưng. Đó là activation, và ta đưa nó ra ngoài. Ta viết nó bằng toán học.
So the activation coming out is a weighted sum of features. So this might be f1 of x. This here, small font — I can't even see what the number is.
Vậy activation đầu ra là tổng có trọng số của các đặc trưng. Đây có thể là f1 của x. Chỗ này chữ nhỏ quá, tôi còn không nhìn ra số gì.
Actually, looks like the 1 is on top. f1 of x comes in here. This one here is w1. And we compute w1 times f1 of x.
À, có vẻ số 1 nằm ở trên. f1 của x đi vào đây. Cái này là w1. Và ta tính w1 nhân f1 của x.
That together gets fed in here, summed together with all the other weighted feature values, or in a dot product notation, which we'll use a lot going forward, w inner product with feature vector f of x.
Rồi nó được đưa vào đây, cộng cùng các giá trị đặc trưng có trọng số khác, hay theo ký hiệu tích vô hướng, thứ ta sẽ dùng nhiều sau này, w nhân trong với vectơ đặc trưng f của x.
If the activation is positive the output will call a positive 1, and we'll have the positive class. If the output is negative, we'll say it's a negative class.
Nếu activation dương thì đầu ra ta gọi là +1, và đó là lớp dương. Nếu đầu ra âm thì ta nói đó là lớp âm.
You might wonder, how can it be negative? Well, these weights could be negative.
Bạn có thể thắc mắc, sao nó âm được? Thì các trọng số có thể âm.
And then if a positive feature value comes in and the weight is negative, you get a negative output if that dominates, or you could have a feature value that's negative and a weight vector that has a positive entry and together, it becomes a negative output.
Nếu một giá trị đặc trưng dương đi vào mà trọng số âm, nếu nó áp đảo thì đầu ra sẽ âm, hoặc có thể giá trị đặc trưng âm còn vectơ trọng số có phần tử dương thì kết hợp lại cũng cho đầu ra âm.
Any questions about this? Because this the basic calculation we're going to be doing for the first half of lecture here.
Có câu hỏi nào về phần này không? Vì đây là phép tính cơ bản mà ta sẽ làm trong nửa đầu buổi học này.
Represented as a network — and we'll see more of these drawings in the future — we have features coming in. In this case, three feature values.
Biểu diễn dưới dạng mạng, và ta sẽ thấy thêm những hình vẽ như vậy sau này, ta có các đặc trưng đi vào. Ở đây là ba giá trị đặc trưng.
Imagine an image with just three pixels that could be on or off. Three feature values coming in.
Hãy tưởng tượng một ảnh chỉ có ba pixel, bật hoặc tắt. Ba giá trị đặc trưng đi vào.
They're being weighted, summed together, and then a decision is made whether the resulting activation is bigger or smaller than 0. So let's look at an example.
Chúng được nhân trọng số, cộng lại, rồi quyết định xem activation kết quả lớn hơn hay nhỏ hơn 0. Ta xem một ví dụ.
We have a weight vector, w, and this weight vector w has entries, just like feature vectors of entries. Just as many entries. And it corresponds.
Ta có vectơ trọng số w, và vectơ w này có các phần tử, giống như vectơ đặc trưng có các phần tử. Số phần tử bằng nhau. Và chúng tương ứng với nhau.
So maybe the weight for "free" is 4, meaning you pay a lot of attention to how often the word "free" occurs.
Có thể trọng số của "free" là 4, nghĩa là bạn rất chú ý đến tần suất xuất hiện của từ "free".
The weight for your name is negative 1, meaning if your name occurs, the activation goes down. In this case, it's supposed be positive when it's spam, negative when it's not spam.
Trọng số của tên bạn là -1, nghĩa là nếu tên bạn xuất hiện thì activation giảm. Ở đây, giá trị dương là khi là spam, âm là khi không phải spam.
So when your name occurs, you want the probability to go down. Then misspelled is 1, because maybe spam emails more often have a misspelling.
Nên khi tên bạn xuất hiện, bạn muốn xác suất giảm xuống. Còn lỗi chính tả là 1, vì có thể email spam thường có lỗi chính tả hơn.
From a friend is negative 3, meaning that you want it to be a negative output if it's from a friend and you have no other signal.
"From a friend" là âm 3, nghĩa là bạn muốn đầu ra là âm nếu email từ bạn bè và không có tín hiệu nào khác.
And this is our weight vector drawn here in 2D space. But if there's four features, really they would be living in a four-dimensional space.
Đây là vectơ trọng số của ta, vẽ trong không gian 2D. Nhưng nếu có bốn đặc trưng thì thực ra chúng nằm trong không gian bốn chiều.
And the dots here mean that, in principle, there's even more features. So it'd be living in a high dimensional space that we can't draw on a slide. Yes.
Và các dấu chấm ở đây nghĩa là về nguyên tắc còn nhiều đặc trưng hơn nữa. Nên nó nằm trong một không gian nhiều chiều mà ta không thể vẽ lên slide. Mời bạn.
STUDENT
Is there a bias term?
Có số hạng bias không ạ?
PROFESSOR
Is there a bias term? You can. So that's a good question. You could start off with a bias here, which is an entry that would be always 1.
Có số hạng bias không? Có thể có. Đó là câu hỏi hay. Bạn có thể thêm một bias ở đây, là một phần tử luôn bằng 1.
And what that would do is, let's say you have no information. If you think most often it's one or the other class, the bias term could push you in that direction.
Tác dụng của nó là, giả sử bạn không có thông tin gì. Nếu bạn nghĩ thường thì rơi vào một trong hai lớp, số hạng bias có thể đẩy bạn về hướng đó.
And it would essentially set a higher bar — if the bias term is positive, it would set a higher bar to be able to conclude that it is not spam.
Về bản chất nó đặt ra một ngưỡng cao hơn, nếu bias dương, nó đặt ngưỡng cao hơn để có thể kết luận đó không phải spam.
Or if the bias term is negative, that would mean that you think, by default, it's not going to be spam.
Còn nếu bias âm, nghĩa là bạn cho rằng mặc định nó không phải spam.
But if there is enough indication for spam, you can get it over zero and classify as spam.
Nhưng nếu có đủ dấu hiệu là spam, bạn có thể vượt qua 0 và phân loại là spam.
And so let's say we assume — maybe we assume almost everything is spam, which, behind the scenes probably is true, and a lot of it we don't see.
Giả sử ta cho rằng gần như mọi thứ đều là spam, điều này có lẽ đúng ngoài đời, và phần lớn ta không nhìn thấy.
Then maybe the bias term would be something like 100 in that by default you think things are going to be spam.
Khi đó bias có thể cỡ 100, vì mặc định bạn nghĩ nó là spam.
But if there's enough evidence otherwise, then you might be able to get this below zero. I haven't told you how we find these weights. For now, just assume that they're there.
Nhưng nếu có đủ bằng chứng ngược lại, thì bạn có thể kéo nó xuống dưới 0. Tôi chưa nói cách tìm các trọng số này. Giờ cứ giả sử chúng đã có sẵn.
It's like your brain's already been trained. It's fixed. It's going to make decisions. But we haven't talked about how we actually train it.
Như thể bộ não của bạn đã được huấn luyện rồi. Nó cố định. Nó sẽ đưa ra quyết định. Nhưng ta chưa nói cách huấn luyện nó.
So this is the weight vector. And the dot product determines whether you're positive or negative.
Đây là vectơ trọng số. Và tích vô hướng quyết định bạn dương hay âm.
So it's very easy to see, if I draw a vector corresponding to some incoming email, I compute the feature vector. If I draw it here, well, it's in the same direction.
Rất dễ thấy: nếu tôi vẽ vectơ ứng với một email đến, tôi tính vectơ đặc trưng. Nếu vẽ ở đây thì nó cùng hướng.
That's a positive, so that's spam. If I draw it in this direction that would be misaligned. That's a negative. That's not spam.
Đó là dương, nên là spam. Nếu vẽ theo hướng này thì nó lệch hướng. Đó là âm. Không phải spam.
And really what you want to look at is, in some sense, the orthogonal plane to that vector.
Và thật ra điều bạn cần nhìn là mặt phẳng trực giao với vectơ đó.
And if you lie on one side of the plane you have a positive inner product, on the other side, a negative inner product. And that's how decisions get made.
Nếu bạn nằm ở một phía của mặt phẳng thì tích vô hướng dương, ở phía kia thì tích vô hướng âm. Quyết định được đưa ra như vậy.
So here's one vector which is pretty spammy. A lot of free. Not your name anywhere. Things are misspelled frequently.
Đây là một vectơ khá giống spam. Nhiều chữ free. Không có tên bạn. Hay viết sai chính tả.
It's not from a friend. And so it's pretty well aligned with this w.
Không phải từ bạn bè. Nên nó khá thẳng hàng với w này.
But then here's another one that looks like maybe a more benign email, and the feature vector points in the other direction. Negative inner product.
Còn đây là một email khác trông lành hơn, và vectơ đặc trưng chỉ về hướng ngược lại. Tích vô hướng âm.
And this one will be the negative class, and this one will end up being in the positive class according to this vector w. If you change w, your decision process will change.
Cái này sẽ thuộc lớp âm, còn cái kia sẽ thuộc lớp dương theo vectơ w này. Nếu đổi w, quá trình quyết định sẽ thay đổi.
So how do we get these decision rules? We have a binary decision rule in the space of feature vectors. The examples are all points. Any weight vector corresponds to a hyperplane.
Vậy làm sao có được các quy tắc quyết định này? Ta có một quy tắc quyết định nhị phân trong không gian các vectơ đặc trưng. Các ví dụ đều là những điểm. Mỗi vectơ trọng số ứng với một siêu phẳng.
What does that mean? A weight vector is a hyperplane. It's the hyperplane orthogonal to that weight vector. And so let's draw this out.
Nghĩa là sao? Một vectơ trọng số là một siêu phẳng. Đó là siêu phẳng trực giao với vectơ trọng số. Ta vẽ ra nhé.
Here is a weight vector. It mostly points towards free and a little bit towards money.
Đây là một vectơ trọng số. Nó chủ yếu hướng về free và một chút về money.
So it would maybe roughly point in this direction. Then we have a bias term. What does that mean?
Nên đại khái nó chỉ theo hướng này. Rồi ta có số hạng bias. Nó nghĩa là gì?
It means that if we did not have a bias term — let's say for now that this was 0 — then our hyperplane would be right here going through zero.
Nghĩa là nếu không có bias, giả sử bây giờ nó bằng 0, thì siêu phẳng sẽ ở ngay đây, đi qua gốc.
Well, it's not a perfect drawing. It should be orthogonal. So maybe this way, going through 0. And this would be the positive class.
Hình vẽ chưa chuẩn lắm. Nó phải trực giao. Nên có lẽ theo hướng này, đi qua 0. Đây là lớp dương.
This would be the negative class. But we actually do have a bias term, and the bias term seems to favor the negative class.
Đây là lớp âm. Nhưng thực ra ta có bias, và bias này có vẻ ưu tiên lớp âm.
So that means this hyperplane is actually shifted over and will be — it's not drawn to scale but will be, let's say, qualitatively somewhere here.
Nghĩa là siêu phẳng thực ra bị dịch sang và sẽ nằm, hình không đúng tỉ lệ, đại khái đâu đó ở đây.
And then everything on this side is negative and on this side is positive. So you could have a point that lies out here.
Mọi thứ phía này là âm và phía này là dương. Có thể có một điểm nằm ngoài đây.
And you would look at the inner product with the weight vector. But then there's also the bias. If this one's far enough out it would be positive.
Bạn sẽ xét tích vô hướng với vectơ trọng số. Nhưng còn có cả bias nữa. Nếu điểm này đủ xa thì nó sẽ dương.
But then, if it's only out here, well, it's not far enough out with the weight vector. It would be negative class.
Nhưng nếu nó chỉ ở đây, thì nó chưa đủ xa theo vectơ trọng số. Nó sẽ thuộc lớp âm.
Let's do this in a more typeset drawing. So we have a decision boundary due to this weight vector. Corresponds to where this equation holds true.
Ta xem lại bằng hình vẽ gọn hơn. Ta có một ranh giới quyết định do vectơ trọng số này tạo ra. Nó ứng với chỗ phương trình này đúng.
One side is negative. Other side is positive.
Một phía là âm. Phía kia là dương.
That's how we make decisions. How do we find w? It's going to be a little different from most things we've seen so far.
Ta ra quyết định như vậy. Làm sao tìm w? Nó sẽ hơi khác so với hầu hết những gì ta đã thấy đến giờ.
We're going to have an iterative algorithm that doesn't just look at the data and says, here is the result, but will loop over the data, look at all the data multiple times until finally it's found something it's happy with.
Ta sẽ có một thuật toán lặp, không chỉ nhìn dữ liệu rồi đưa ra kết quả ngay, mà sẽ duyệt qua dữ liệu, xem toàn bộ dữ liệu nhiều lần cho đến khi cuối cùng tìm được một kết quả mà nó hài lòng.
So it'll do an update, update, update, till finally it converges.
Nên nó sẽ cập nhật, cập nhật, cập nhật, cho đến khi cuối cùng hội tụ.
A bit like the local search we did in [INAUDIBLE],, where you wouldn't right away find a solution but try to improve it over time till finally you find something good.
Hơi giống tìm kiếm cục bộ mà chúng ta đã làm trong [KHÔNG NGHE RÕ], nơi ta không tìm ra ngay lời giải mà cải thiện dần theo thời gian cho đến khi tìm được thứ tốt.
So we start with all the weights it's equal to 0, let's say. That's a reasonable thing to do. Then, for each training instance, we classify with the current weights.
Ta bắt đầu với tất cả trọng số bằng 0, chẳng hạn. Đó là một cách làm hợp lý. Sau đó, với mỗi mẫu huấn luyện, ta phân loại bằng các trọng số hiện tại.
So you run the classifier with the current weights. If this is your current classifier and these are data points, then that should be the case that it will be correct.
Tức là chạy bộ phân loại với trọng số hiện tại. Nếu đây là bộ phân loại hiện tại và đây là các điểm dữ liệu, thì có thể nó sẽ phân loại đúng.
You feed in a data point or made the correct decision. y star means the correct decision. y is the decision the perceptron is making.
Bạn đưa vào một điểm dữ liệu và nó quyết định đúng. y star là quyết định đúng. y là quyết định mà perceptron đưa ra.
They're equal, will be no change needed, and you go on to the next data point.
Nếu chúng bằng nhau, không cần thay đổi gì, và bạn chuyển sang điểm dữ liệu tiếp theo.
On the other hand, if it's wrong, like you might have in this drawing over here, and if you're looking at this data point, then an adjustment will be made to the weight vector to try to make it more compatible with the data point that we just saw.
Ngược lại, nếu nó sai, như có thể thấy trong hình này, và nếu bạn đang xét điểm dữ liệu này, thì vectơ trọng số sẽ được điều chỉnh để phù hợp hơn với điểm dữ liệu vừa thấy.
And then this process repeats until ultimately, hopefully, it's compatible with all data points that are in our data set. Let's look at this a little bit more concretely.
Rồi quá trình này lặp lại cho đến khi, hy vọng là, nó phù hợp với mọi điểm dữ liệu trong tập dữ liệu. Ta hãy xem cụ thể hơn một chút.
We classify with the current weights. So we have a weight vector. We have a feature vector. We compute the dot product, w times f of x.
Ta phân loại bằng trọng số hiện tại. Ta có một vectơ trọng số. Ta có một vectơ đặc trưng. Ta tính tích vô hướng, w nhân f của x.
And we check if it's positive or negative. That'll tell us whether it's correct or incorrect.
Và kiểm tra nó dương hay âm. Điều đó cho biết kết quả đúng hay sai.
Now if it's correct, if the true label was positive in our algorithm, we have to do nothing because it was predicted as positive, the true label is positive, no update.
Nếu đúng, tức nhãn thật là dương, thì trong thuật toán ta không làm gì vì nó được dự đoán là dương, nhãn thật là dương, không cập nhật.
But what if the true label is negative? So what if y star is negative 1? What will happen?
Nhưng nếu nhãn thật là âm thì sao? Tức là y star bằng âm 1? Chuyện gì xảy ra?
Well, we'll make the wrong decision here because the inner product is positive and we should be negative. So you want to adjust the weight vector.
Ta sẽ quyết định sai ở đây vì tích vô hướng là dương mà lẽ ra phải âm. Nên ta muốn điều chỉnh vectơ trọng số.
f we cannot adjust here. f is just a description of the input, and that's how we capture what we're getting.
Ta không chỉnh f được. f chỉ là mô tả của đầu vào, là cách ta nắm bắt dữ liệu nhận được.
w is our decision making process, and we can change that and try to improve it. So how can we change it?
w là quá trình ra quyết định của ta, và ta có thể thay đổi nó để cải thiện. Vậy thay đổi thế nào?
Well, if y star is negative 1, so it's wrong, what we can do is we can say, well, we'd love for w to be not as aligned with f.
Nếu y star là âm 1, tức là nó sai, thì ta có thể nói rằng ta muốn w bớt cùng hướng với f.
So what does that mean, not as aligned with f? Well, in some sense that means more aligned with the negative of f. So we can make w more aligned with the negative of f.
Bớt cùng hướng với f nghĩa là gì? Theo một nghĩa nào đó, là cùng hướng hơn với âm của f. Nên ta làm w cùng hướng hơn với âm của f.
That will make it less aligned with f. So how do we do that? We can just essentially add y star times f.
Như vậy w sẽ bớt cùng hướng với f. Làm thế nào? Về cơ bản ta chỉ cần cộng y star nhân f.
In this picture what it would look like is we have y star times f or y star negative, pointing the opposite way.
Trong hình này, nó trông như thế này: ta có y star nhân f, hay y star âm, chỉ hướng ngược lại.
We can add it to w, and we end up over here with our new w. Let's say w prime, which is the one we get after the update.
Ta cộng nó vào w, và có w mới ở đây. Gọi là w prime, là w sau khi cập nhật.
This new w, w prime, will be less aligned with f, which is what we want because you want it to be a negative inner product. How do we know this for sure?
w mới này, w prime, sẽ bớt cùng hướng với f, đúng như ta muốn vì ta muốn tích vô hướng âm. Làm sao biết chắc điều này?
We can do some math. So let's call this w prime.
Ta có thể tính toán. Gọi nó là w prime.
After the update we have w prime inner product with f is equal to, well, the original w plus — in this case, y star was negative 1 but let's just say y star for now, times f inner product with f, which
Sau khi cập nhật, tích vô hướng của w prime với f bằng, w ban đầu cộng ở đây y star là âm 1 nhưng cứ gọi là y star, nhân f, rồi lấy tích vô hướng với f, tức là
is w inner product with f plus y star times f inner product with itself. This is the original, and this is the correction.
w nhân vô hướng f cộng y star nhân f nhân vô hướng với chính nó. Đây là giá trị ban đầu, còn đây là phần hiệu chỉnh.
So after we did the correction, the inner product has changed. How has it changed? f times f is always bigger than 0.
Sau khi hiệu chỉnh, tích vô hướng đã thay đổi. Nó thay đổi thế nào? f nhân f luôn lớn hơn 0.
So when y star is positive, the inner product will have gone up. When y star is negative, the inner product will have gone down. That's exactly what we want.
Nên khi y star dương, tích vô hướng sẽ tăng lên. Khi y star âm, tích vô hướng sẽ giảm xuống. Đúng như ta muốn.
So it's a very, very simple update rule that ensures that the inner product moves in the direction we want it to move.
Đây là một quy tắc cập nhật rất đơn giản đảm bảo tích vô hướng di chuyển theo hướng ta mong muốn.
Pictorially what it means, if y star is negative, we see the weight vector rotate away from f. And if y star is positive, we'll see the weight vector rotate closer to f.
Nhìn trực quan, nếu y star âm, vectơ trọng số quay ra xa f. Còn nếu y star dương, vectơ trọng số quay lại gần f hơn.
Any questions about this? This is our first algorithm. This is the perceptron.
Có câu hỏi nào về phần này không? Đây là thuật toán đầu tiên của ta. Đây là perceptron.
Yes?
Bạn hỏi đi?
STUDENT
Is there a way to control the rate of convergence?
Có cách nào kiểm soát tốc độ hội tụ không ạ?
PROFESSOR
So the question is, look at this — I mean, it gets one example, and it seems to be swept all the way over. And maybe that's overfitting.
Câu hỏi là, nhìn này, nó chỉ nhận một ví dụ mà dường như bị xoay đi hẳn. Và có thể đó là quá khớp.
It's paying too much attention to this one example. And indeed, learning rates is what you would use to make the steps of the size that is more appropriate.
Nó chú ý quá nhiều vào một ví dụ này. Đúng vậy, tốc độ học là thứ ta dùng để làm cho các bước có kích thước phù hợp hơn.
We're going to look at that in next lecture. Not today. It does turn out that, under certain assumptions, this works just fine, even without having a learning rate.
Ta sẽ xem phần đó ở bài giảng sau. Không phải hôm nay. Thực ra, với một số giả định nhất định, cách này vẫn chạy tốt, kể cả không có tốc độ học.
So it's not necessarily wrong to do it without a learning rate but definitely some more sophisticated approaches.
Nên làm mà không có tốc độ học chưa chắc là sai, nhưng chắc chắn có những cách tinh vi hơn.
We'll do an update where they will multiply this with some alpha, just like we did in Q-learning, to make the adjustment more gradual. There was another question. Yes.
Ta sẽ cập nhật bằng cách nhân phần này với một alpha nào đó, giống như trong Q-learning, để việc điều chỉnh diễn ra từ từ hơn. Còn một câu hỏi nữa. Mời em.
STUDENT
Could you relate it to the feature-based?
Thầy có thể liên hệ với phương pháp dựa trên đặc trưng không ạ?
PROFESSOR
Is it related to — STUDENT: The feature-based Q-learning?
Có liên quan với... Q-learning dựa trên đặc trưng ạ?
PROFESSOR
Is this related to feature-based Q-learning? In many ways it is. In feature-based Q learning we had notion of the Q value is weight vector times feature vector.
Cái này có liên quan đến Q-learning dựa trên đặc trưng không? Về nhiều mặt thì có. Trong Q-learning dựa trên đặc trưng, giá trị Q bằng vectơ trọng số nhân vectơ đặc trưng.
In Q-learning, we wanted the result of that inner product to be a Q value.
Trong Q-learning, ta muốn kết quả của tích vô hướng đó là một giá trị Q.
Here, the way we use the resulting inner product is to make a decision as to whether it's positive or negative, which indicates which class we are in. But there's definitely a lot of similarity.
Còn ở đây, ta dùng tích vô hướng đó để quyết định nó dương hay âm, và điều đó cho biết ta thuộc lớp nào. Chắc chắn có nhiều điểm giống nhau.
But the learning is very different because in Q-learning, we learn with an approximation to the Baumann equation based on samples, and here we learn essentially through supervision of whether something should be positive or negative.
Nhưng cách học rất khác, vì trong Q-learning, ta học bằng một xấp xỉ của phương trình Bellman dựa trên các mẫu, còn ở đây ta học về cơ bản nhờ giám sát, tức biết cái gì nên dương hay nên âm.
So we get a lot more signal here. In Q-learning you have to bootstrap. And you were doing it based on some estimate of what the Q value would be at the next state.
Nên ở đây ta có nhiều tín hiệu hơn hẳn. Trong Q-learning bạn phải bootstrap. Bạn làm dựa trên một ước lượng về giá trị Q ở trạng thái kế tiếp.
That was kind of approximate. Whereas here somebody tells you, this data point, this f of x, should have a positive label, or they tell you, this f of x should have a negative label.
Cái đó chỉ là xấp xỉ. Còn ở đây có người cho bạn biết điểm dữ liệu này, f của x này, phải có nhãn dương, hoặc f của x này phải có nhãn âm.
So a lot more signal here to learn from.
Vậy ở đây có nhiều tín hiệu hơn để học.
That was the binary perceptron.
Đó là perceptron nhị phân.
In a separable case — meaning the data points you have are laid out in a way that there exists a hyperplane, or in two dimensions a line that separates them apart in the class categories — this is how it could play out.
Trong trường hợp khả tách, nghĩa là các điểm dữ liệu được bố trí sao cho tồn tại một siêu phẳng, hay trong hai chiều là một đường thẳng, tách các lớp ra, thì nó diễn ra như thế này.
Here's your separable data set. You look at one example. It changes your hyperplane. You look at another example.
Đây là tập dữ liệu khả tách. Bạn xét một mẫu. Siêu phẳng thay đổi. Xét mẫu khác.
Shifts around again. As we said, it might jump a little much. But then over time, it'll stop jumping around.
Lại dịch chuyển. Như đã nói, nó có thể nhảy hơi nhiều. Nhưng theo thời gian, nó sẽ thôi nhảy lung tung.
It will be right in the middle here — not exactly in the middle but separating the two classes.
Nó sẽ nằm ở giữa đây, không hẳn chính giữa nhưng tách được hai lớp.
When we now cycle to the next data point it will be correct, which will mean no update. We go to the next data point, it'll be already correct, which means no update.
Khi ta chuyển sang điểm dữ liệu kế tiếp, nó sẽ đúng, nên không cập nhật. Sang điểm tiếp theo, nó đã đúng rồi, nên không cập nhật.
And the algorithm has converged. How about multiple classes? It's pretty exceptional you would only have two classes to decide between.
Và thuật toán đã hội tụ. Còn nhiều lớp thì sao? Hiếm khi chỉ có hai lớp để chọn.
Let's say we have three or more classes, and we'll use three as a running example. How to go about that. One way to do it is to have a weight vector per class.
Giả sử có ba lớp trở lên, và ta dùng ba lớp làm ví dụ xuyên suốt. Làm thế nào? Một cách là dùng một vectơ trọng số cho mỗi lớp.
So instead of having w times f of x positive versus negative determines the class, for each class, we have a wy.
Thay vì w nhân f của x dương hay âm quyết định lớp, ta có một wy cho mỗi lớp.
For example, three class classification problem, we have a w1, a w2, w3 corresponding to each of the three classes. And each will point in the direction that that class's data points live.
Ví dụ bài toán phân loại ba lớp, ta có w1, w2, w3 tương ứng với ba lớp. Mỗi vectơ chỉ về hướng nơi các điểm dữ liệu của lớp đó nằm.
You compute the activation for a class y, wy times f of x. And then you can see which one has the highest activation. And that's your decision.
Bạn tính độ kích hoạt cho lớp y, wy nhân f của x. Rồi xem lớp nào có độ kích hoạt cao nhất. Đó là quyết định của bạn.
It's not identically matched with a two class. Like if you said, oh, what if instead of three we had two classes?
Nó không khớp hoàn toàn với trường hợp hai lớp. Chẳng hạn bạn hỏi, nếu thay vì ba lớp ta chỉ có hai lớp thì sao?
If you use this approach, you'd have a weight vector for the positive class and another weight vector for the negative class.
Nếu dùng cách này, bạn sẽ có một vectơ trọng số cho lớp dương và một vectơ trọng số khác cho lớp âm.
In the two class case you can also simplify it to only have one weight vector. That's what we did.
Với hai lớp, bạn cũng có thể đơn giản hóa chỉ còn một vectơ trọng số. Đó là điều ta đã làm.
In the multi-class case, you can't really do it that way, and we'll have one weight vector per class.
Với nhiều lớp thì không làm vậy được, và ta sẽ có một vectơ trọng số cho mỗi lớp.
And so here's what it pictorially could look like. You have three weight vectors pointing in their own directions, and then the regions in that direction would correspond to those classes.
Hình ảnh của nó có thể trông như thế này. Có ba vectơ trọng số chỉ về các hướng riêng, và các vùng theo hướng đó sẽ tương ứng với các lớp đó.
It's a little more subtle than that because we're looking at the inner product.
Thực ra tinh tế hơn một chút vì ta đang xét tích vô hướng.
So if the vector is really, really long — let's say this w3 was super, super long, out of the slide, way out there — then this decision boundary might look more like this.
Nếu vectơ rất, rất dài, giả sử w3 này siêu dài, ra khỏi slide, tận đằng xa kia, thì ranh giới quyết định sẽ trông giống thế này.
And it might take up more. Because it's so long, its inner product will be larger.
Và nó có thể chiếm nhiều chỗ hơn. Vì nó dài, tích vô hướng sẽ lớn hơn.
Similarly if this w3 was really short and only came up to here, then this would shrink a little bit and maybe only be this big.
Tương tự nếu w3 rất ngắn, chỉ tới đây, thì vùng này sẽ co lại, có lẽ chỉ to cỡ này.
If they're all the same size, then it's just dividing up the space based on the angles.
Nếu chúng cùng độ dài thì không gian chỉ được chia theo góc.
So that's how we can make decisions into multi-class. How about training this thing? We can use the same procedure, actually, with a very, very minor modification.
Đó là cách ta ra quyết định cho nhiều lớp. Còn huấn luyện thì sao? Thực ra ta dùng cùng quy trình, chỉ sửa đổi rất ít.
We're going to start with all weights equal to zero which, now, if we had a three class problem, means three weight vectors, each of them having all equal to 0 with some tie-breaking happening in the beginning.
Ta bắt đầu với mọi trọng số bằng không, nghĩa là nếu có bài toán ba lớp, thì ba vectơ trọng số, mỗi cái toàn bằng 0, và lúc đầu phải phá thế hòa bằng một cách nào đó.
We pick up training examples one by one. And we predict with the current weights. We see what the prediction is.
Ta lấy từng mẫu huấn luyện một. Và dự đoán bằng trọng số hiện tại. Ta xem dự đoán là gì.
If the prediction is correct, then our weights are good as far as this training example is concerned and we don't have to do any update.
Nếu dự đoán đúng, thì trọng số ổn với mẫu huấn luyện này và ta không cần cập nhật.
However, if the prediction is incorrect — let's say, for this feature vector we would predict class y but the class label is actually y star, then we need to somehow rotate wy and wy star, such than wy star has a higher inner product with f than wy.
Tuy nhiên, nếu dự đoán sai, giả sử với vectơ đặc trưng này ta dự đoán lớp y nhưng nhãn thật là y sao, thì ta phải xoay wy và wy sao sao cho wy sao có tích vô hướng với f cao hơn wy.
How are we going to do this? Well, we can use essentially the same trick as we did before, by adding or subtracting the feature vector to the weight vector.
Ta sẽ làm thế nào? Về cơ bản ta dùng cùng mẹo như trước, là cộng hoặc trừ vectơ đặc trưng vào vectơ trọng số.
So wy we want lower inner product because we didn't want the outcome to be y. So we're going to subtract out f. This here is negative f.
Với wy ta muốn tích vô hướng thấp hơn vì ta không muốn kết quả là y. Nên ta sẽ trừ đi f. Đây là âm f.
It's being added on to wy. We have a new wy prime. And for wy star we want a higher inner product, so we add it on.
Nó được cộng vào wy. Ta có một wy phẩy mới. Còn với wy sao, ta muốn tích vô hướng cao hơn, nên ta cộng vào.
And we end up with a new wy star prime. And same thing.
Và ta có một wy sao phẩy mới. Cũng tương tự.
If we look at the inner products, we look at wy prime with f of x, which is wy minus f of x times f of x, which is wy times f of x minus f of x inner product with f of x.
Nếu xét các tích vô hướng, ta xét wy phẩy với f của x, bằng wy trừ f của x, nhân f của x, bằng wy nhân f của x trừ tích vô hướng của f của x với chính nó.
This is the original. This part, inner product of vector with itself, is always bigger than 0. We subtract it out.
Đây là giá trị ban đầu. Phần này, tích vô hướng của một vectơ với chính nó, luôn lớn hơn 0. Ta trừ nó đi.
So the resulting weight vector wy prime has a lower inner product than the original one, which is what we want. And for wy star we can do the same calculation.
Vậy vectơ trọng số wy phẩy kết quả có tích vô hướng thấp hơn vectơ ban đầu, đúng như ta muốn. Với wy sao ta tính tương tự.
There's a positive here, so this negative would be a positive. And we would find that the inner product has increased. Does it mean that after this update wy star will win?
Ở đây có dấu dương, nên dấu âm này thành dương. Và ta thấy tích vô hướng đã tăng lên. Vậy sau lần cập nhật này wy sao có thắng không?
We don't know that. That's not guaranteed. But we know that at least it'll have a higher inner product than before and wy will have a lower inner product than before.
Ta không biết. Điều đó không được đảm bảo. Nhưng ta biết ít nhất nó sẽ có tích vô hướng cao hơn so với trước, còn wy sẽ có tích vô hướng thấp hơn so với trước.
So we nudge things in the right direction. Do we nudge them far enough? Too far? We don't know.
Vậy ta đẩy mọi thứ đi đúng hướng. Đẩy đủ xa chưa? Hay quá xa? Ta không biết.
But we at least nudged in the right direction.
Nhưng ít nhất ta đã đẩy đúng hướng.
OK. Let's take a look at this in action in a demo.
OK. Hãy xem điều này hoạt động qua một bản demo.
So let's reset this. We have a bunch of data points. There are three classes — there's a blue class, a red class, and a green class.
Ta đặt lại nhé. Ta có một loạt điểm dữ liệu. Có ba lớp: lớp xanh dương, lớp đỏ và lớp xanh lá.
We have random initial weight vectors — a red one pointing this way, a blue one pointing this way, and a green one pointing this way. It's kind of interesting here.
Ta có các vectơ trọng số khởi tạo ngẫu nhiên: vectơ đỏ chỉ hướng này, xanh dương hướng này, và xanh lá hướng này. Chỗ này khá thú vị.
The red one actually points in the blue region. How is that even possible that the red is not surrounded by red? That's because the blue one is longer.
Vectơ đỏ thực ra chỉ vào vùng xanh dương. Sao có thể như vậy, vectơ đỏ lại không được bao quanh bởi vùng đỏ? Vì vectơ xanh dương dài hơn.
And because it's longer, the inner product is higher and it can take over, in some sense, some of that angular space of the red one, which only has this region over here.
Vì dài hơn nên tích vô hướng cao hơn và nó có thể chiếm bớt phần không gian góc của vectơ đỏ, vốn chỉ còn vùng ở đây.
So first data point. So we cycle through the algorithm. We're training. We get a data point.
Điểm dữ liệu đầu tiên. Ta chạy lần lượt qua thuật toán. Ta đang huấn luyện. Ta lấy một điểm dữ liệu.
It's a blue one. It should be classified as red. So first step is compute the label. It'll be red.
Đó là điểm xanh dương. Nó lẽ ra phải được phân loại là đỏ. Bước đầu là tính nhãn. Nó sẽ là đỏ.
Then — oops, this is going very fast. Let me reset this.
Rồi, ôi, chạy nhanh quá. Để tôi đặt lại.
This is going too fast.
Nhanh quá.
OK. Let's finish training. Reset. It's on autopilot for some reason.
OK. Ta huấn luyện cho xong. Đặt lại. Không hiểu sao nó tự chạy.
OK. Stopped. So we have a current data point here, which is green. It computed the label.
OK. Đã dừng. Điểm dữ liệu hiện tại ở đây màu xanh lá. Nó đã tính nhãn.
It's going to check, is the computer label equal to the actual label? In this case it is equal because it will compute green and it is green.
Nó sẽ kiểm tra xem nhãn tính được có bằng nhãn thực không. Trường hợp này là bằng, vì nó tính ra xanh lá và điểm đúng là xanh lá.
So when we step, it'll skip over this, look at the next training example. It'll compute the label for the next training sample, which is blue, which is correct.
Nên khi bước tiếp, nó bỏ qua bước này, xét ví dụ huấn luyện kế tiếp. Nó tính nhãn cho mẫu huấn luyện tiếp theo, là xanh dương, và đúng.
So again, it will skip over the — oh, that's green. Didn't see that right. So this is green. Apologies.
Nên lại bỏ qua phần, ồ, đó là xanh lá. Tôi nhìn nhầm. Đây là xanh lá. Xin lỗi.
Green dot under the yellow arrow. So that's wrong in terms of it predicting blue. Then what it's going to do is it's going to change the way it vectors.
Chấm xanh lá dưới mũi tên vàng. Vậy là sai, vì nó dự đoán xanh dương. Khi đó nó sẽ thay đổi các vectơ.
It's going to change the weight vector for green and for blue. The green one should become more aligned with this data point here.
Nó sẽ đổi vectơ trọng số của xanh lá và xanh dương. Vectơ xanh lá nên căn chỉnh gần hơn với điểm dữ liệu này.
So it's the first thing we do for the — let's see. Computed label. Hold on. Let me reset this.
Đó là việc đầu tiên ta làm cho, để xem. Nhãn tính được. Khoan. Để tôi đặt lại.
We have a weight vector for blue, which is the one over here, green over here. It computed blue because it's in a blue region.
Ta có vectơ trọng số cho xanh dương, là cái ở đây, xanh lá ở đây. Nó tính ra xanh dương vì điểm nằm trong vùng xanh dương.
It's checking for the computed label, which is blue. It shouldn't be blue so it should subtract out this vector.
Nó kiểm tra nhãn tính được, là xanh dương. Lẽ ra không phải xanh dương, nên phải trừ đi vectơ này.
So we're going to see this blue one, get this thing subtracted out in the next step here. Then it's looking at the green one.
Ta sẽ thấy vectơ xanh dương này bị trừ đi ở bước kế tiếp. Rồi nó xét vectơ xanh lá.
The green one should be more aligned with the yellow one, the data point. So we'll see the green one rotate towards the data point. And then it goes to the next one.
Vectơ xanh lá nên căn chỉnh gần hơn với điểm dữ liệu màu vàng. Nên ta sẽ thấy vectơ xanh lá xoay về phía điểm dữ liệu. Rồi nó sang điểm tiếp theo.
Next data point up here is blue. The computed label is red, so that's not good.
Điểm dữ liệu kế tiếp ở trên này là xanh dương. Nhãn tính được là đỏ, vậy là không tốt.
It'll say, OK, I need to first make sure that I don't predict or predict less likely red. So red should point less in this direction.
Nó sẽ nói: OK, trước hết tôi cần đảm bảo không dự đoán đỏ, hoặc ít có khả năng dự đoán đỏ hơn. Nên vectơ đỏ phải bớt chỉ về hướng này.
And we'll see red rotate away in this first update step here. And blue should point more in that direction, and we'll see it rotate towards that data point.
Và ta sẽ thấy vectơ đỏ xoay ra xa ở bước cập nhật đầu tiên này. Còn vectơ xanh dương nên chỉ nhiều hơn về hướng đó, và ta sẽ thấy nó xoay về phía điểm dữ liệu đó.
And this process repeats. Right now we're here. It predicted green and it is green, so it'll skip over any updates. Am I seeing the colors wrong again?
Quá trình này cứ lặp lại. Bây giờ ta đang ở đây. Nó dự đoán xanh lá và đúng là xanh lá, nên nó bỏ qua mọi cập nhật. Tôi lại nhìn nhầm màu nữa à?
It's rotating red away and rotating green towards. And this process just repeats. It has the next data point up here. It's going to compute it as blue as its decision.
Nó xoay vectơ màu đỏ ra xa và xoay vectơ màu xanh lá lại gần. Và quá trình này cứ lặp lại. Điểm dữ liệu tiếp theo ở trên này. Nó sẽ tính ra quyết định là màu xanh dương.
It actually is blue so it should skip over this. It skipped over it. Great. It goes to the next one.
Thực tế nó đúng là xanh dương nên sẽ bỏ qua bước cập nhật. Nó đã bỏ qua. Tốt. Nó chuyển sang điểm tiếp theo.
That one kind of falls out of the screen. Not sure which color it has. It's going to check, is the color predicted? It'll predict green.
Điểm đó nằm ra ngoài màn hình. Không chắc nó màu gì. Nó sẽ kiểm tra xem màu dự đoán có đúng không. Nó sẽ dự đoán màu xanh lá.
Is that equal to the actual label? The label looks like it's blue so it's not the same. So it's going to rotate the blue one away from this and the green one towards it.
Có bằng nhãn thật không? Nhãn có vẻ là xanh dương nên không giống nhau. Vậy nó sẽ xoay vectơ xanh dương ra xa khỏi điểm này và xoay vectơ xanh lá lại gần.
It seems to have some bugs or my color ratings are off. Let's finish training.
Có vẻ nó có lỗi, hoặc tôi nhìn màu bị sai. Cho nó huấn luyện xong.
And after it's gone through all the examples till it doesn't change anymore we have all the green in the green region over here, all the blue in the blue region over here, and all the red in the red region over here.
Và sau khi nó chạy qua tất cả các ví dụ cho đến khi không còn thay đổi nữa, ta có tất cả điểm xanh lá nằm trong vùng xanh lá ở đây, tất cả điểm xanh dương trong vùng xanh dương ở đây, và tất cả điểm đỏ trong vùng đỏ ở đây.
At this point, whenever it grabs a new data point, it will see that it already agrees with it and it will do no updates. And it's fully converged.
Lúc này, mỗi khi lấy một điểm dữ liệu mới, nó thấy mình đã đồng ý với nhãn và sẽ không cập nhật gì. Và nó đã hội tụ hoàn toàn.
You can reset this and play with the app, and you'll see it cycle through a different versions of the data set and iteratively improved the weight vectors.
Các bạn có thể đặt lại và chơi với ứng dụng này, và sẽ thấy nó chạy qua các phiên bản khác nhau của tập dữ liệu và cải thiện dần các vectơ trọng số.
So it's very different from most algorithms we've seen till today in that here there is not a one-time update. You don't just look once at the data and then you know the answer.
Nên nó rất khác so với hầu hết các thuật toán ta đã thấy đến nay, ở chỗ ở đây không có cập nhật một lần. Bạn không chỉ nhìn dữ liệu một lần rồi biết ngay đáp án.
You keep cycling through the data until, at some point, things stop changing. And that's when you declare success. Any questions about this?
Bạn cứ lặp qua dữ liệu cho đến khi, tại một lúc nào đó, mọi thứ ngừng thay đổi. Và đó là lúc bạn tuyên bố thành công. Có câu hỏi nào về phần này không?
Question over there. Yes.
Câu hỏi ở đằng kia. Vâng.
STUDENT
If the data is linearly separable, are we guaranteed that perceptrons will converge to the correct boundaries? Or is there a situation where you could ping-pong back and forth and never converge?
Nếu dữ liệu khả tách tuyến tính, liệu perceptron có chắc chắn hội tụ đến ranh giới đúng không? Hay có tình huống nó cứ dao động qua lại và không bao giờ hội tụ?
PROFESSOR
So that's a good question. So are we guaranteed, if there is a solution, that we find it? And sometimes it's like completeness in the original lectures on search.
Đó là câu hỏi hay. Nếu có nghiệm thì ta có chắc chắn tìm được nó không? Cũng giống tính đầy đủ trong các bài giảng đầu về tìm kiếm.
If a solution exists do you find it? Do we have the same completeness guarantee for perceptron? In the binary perceptron, if data are linearly separable, then it might bounce around for a while.
Nếu nghiệm tồn tại thì bạn có tìm ra không? Perceptron có đảm bảo đầy đủ như vậy không? Với perceptron nhị phân, nếu dữ liệu khả tách tuyến tính, thì nó có thể dao động một lúc.
But ultimately it will find the decision boundary that separates your data. Otherwise, there is no guarantees.
Nhưng cuối cùng nó sẽ tìm ra ranh giới quyết định phân tách dữ liệu của bạn. Nếu không thì không có đảm bảo nào.
This is an example that — actually, let's take a break here. And let's work through this example after the break.
Đây là một ví dụ — thực ra, ta nghỉ giải lao ở đây. Và ta sẽ làm ví dụ này sau giờ nghỉ.
PROFESSOR
OK. Let's restart. Any questions about the first half?
Được rồi. Ta bắt đầu lại. Có câu hỏi nào về nửa đầu không?
Let's do this example then. Multi-class perceptron. We have currently three weight vectors — one for sports, one for politics, one for tech.
Vậy ta làm ví dụ này. Perceptron nhiều lớp. Hiện ta có ba vectơ trọng số — một cho thể thao, một cho chính trị, một cho công nghệ.
And so we're trying to classify whether a sentence is about one of these three categories. We get in the first sentence "win the vote." What would be the weight vector for this first sentence?
Ta đang cố phân loại một câu thuộc một trong ba chủ đề này. Câu đầu tiên là "win the vote." Vectơ đặc trưng của câu đầu này là gì?
Well, it'll have a bias term. It has to "win." Oops, where did it go? It has "win," which is not a 1.
Nó có một số hạng bias. Nó có "win." Ơ, nó đâu rồi? Có "win," chỗ này không phải 1.
Then it doesn't have "game." Oh, come on. Doesn't have "game." It has "vote," and it has "the."
Rồi nó không có "game." Trời ạ. Không có "game." Có "vote," và có "the."
So that's our feature vector for this sentence. If we inner product with sports we get — inner product with this guy we get 1.
Đó là vectơ đặc trưng của câu này. Nhân trong với thể thao ta được — nhân trong với vectơ này ta được 1.
Inner product with this guy we get 0. Inner product with this guy we get 0. So sports would win with our current settings of the weight vectors, which is not what we want.
Nhân trong với vectơ này ta được 0. Nhân trong với vectơ này ta được 0. Vậy thể thao thắng với các trọng số hiện tại, mà đó không phải điều ta muốn.
Let's say we want this to be about politics. So our y star would be politics. Then what happens?
Giả sử ta muốn câu này thuộc chính trị. Vậy y sao sẽ là chính trị. Thế thì chuyện gì xảy ra?
Well, we will subtract this weight vector from the sports one to make sports less aligned with the weight vector. So we'll do — oh, come on, screen.
Ta sẽ trừ vectơ đặc trưng này khỏi vectơ trọng số thể thao để làm thể thao bớt thẳng hàng với vectơ đặc trưng. Vậy ta làm — trời ơi, màn hình.
We'll do minus 1 minus 1 minus 0 minus 1 minus 1, which results in a negative 1, negative 1, 0, negative 1, negative 1 weight vector.
Ta làm trừ 1 trừ 1 trừ 0 trừ 1 trừ 1, ra vectơ trọng số âm 1, âm 1, 0, âm 1, âm 1.
And we'll add it to politics, which will result in — this is all zeros, so this will result in a 1 1 0 1 1 weight vector. Then we go to our next example.
Và ta cộng vào chính trị, kết quả sẽ là — toàn số không, nên sẽ ra vectơ trọng số 1 1 0 1 1 . Rồi ta sang ví dụ tiếp theo.
So we did this one. We'll go to this one. "Win the election" was the weight vector for this one. Bias is always 1.
Vậy ta xong câu này. Ta sang câu này. "Win the election" là vectơ đặc trưng của câu này. Bias luôn là 1.
Then does "win" appear? Yes. That's a 1. Does "game" appear?
Còn "win" có xuất hiện không? Có. Đó là 1. "game" có xuất hiện không?
No. That's a 0. Does "vote" appear? No.
Không. Đó là 0. "vote" có xuất hiện không? Không.
That's a 0. Does "the" appear? Yes. That's a 1.
Đó là 0. "the" có xuất hiện không? Có. Đó là 1.
We inner product with each of these weight vectors. And what do we get for the first one? We get negative 1 plus negative 1 plus 0 plus 0 plus negative 1.
Ta nhân trong với từng vectơ trọng số này. Với vectơ đầu tiên ta được gì? Ta được âm 1 cộng âm 1 cộng 0 cộng 0 cộng âm 1.
So we get a negative 3. For politics we get a 1 plus 1 plus 0 plus 0 plus 1. We get a plus 3. And for technology we get a 0.
Vậy ta được âm 3. Với politics, ta có 1 cộng 1 cộng 0 cộng 0 cộng 1. Ta được cộng 3. Còn với technology thì ta được 0.
So now the class predicted is politics, which, let's say, we think is the right thing here, the correct label, so no changes to the weight vectors.
Vậy lớp được dự đoán bây giờ là politics, và giả sử đó là kết quả đúng ở đây, nhãn đúng, nên không cần thay đổi các vectơ trọng số.
We go on to the next one, "win the game." What's the weird vector for this one? Weight vector bias is always 1.
Ta chuyển sang câu tiếp theo, "win the game". Vectơ đặc trưng của câu này là gì? Trọng số bias luôn bằng 1.
There is a "win," there is a "game," there is no "vote," and there is a "the." Let's look at the inner products with each of our current weight vectors.
Có "win", có "game", không có "vote", và có "the". Hãy xem tích vô hướng với từng vectơ trọng số hiện tại. vectơ.
For the first one, which is negative, negative, 0, negative, negative, we get a negative 3. For the second one, politics, we get a plus 3. And for technology, we get 0 again.
Với vectơ đầu tiên, tức là âm, âm, 0, âm, âm, ta được âm 3. Với vectơ thứ hai, politics, ta được cộng 3. Còn technology thì lại được 0.
So politics wins. But we don't want politics to win this and we want sports to win, so we're going to subtract this feature vector from the politics one.
Vậy politics thắng. Nhưng ta không muốn politics thắng ở đây mà muốn sports thắng, nên ta sẽ trừ vectơ đặc trưng này khỏi vectơ của politics.
So we're going to subtract out. There's our current weight vector.
Vậy ta sẽ trừ đi. Đây là vectơ trọng số hiện tại.
We're going to subtract out this one, which is 1 1 1 0 1, which results in a 0 0 negative 1 1 0.
Ta trừ đi vectơ này, là 1 1 1 0 1, kết quả là 0 0 âm 1 1 0.
New weight vector for politics.
Đó là vectơ trọng số mới cho politics.
And we're going to add it to the sports one, 1 1 1 0 1, which will give us a new weight vector for sports, which is 0 0 1 negative 1 0.
Và ta cộng nó vào vectơ của sports, 1 1 1 0 1, cho ra vectơ trọng số mới của sports, là 0 0 1 âm 1 0.
What happens now?
Giờ thì sao?
We go back to the first one, win the vote, and we keep cycling until we do a full pass through all the data points without any update, at which point no updates will ever happen anymore and we call it done.
Ta quay lại câu đầu, win the vote, và cứ lặp như vậy cho đến khi duyệt hết toàn bộ các điểm dữ liệu mà không có cập nhật nào, lúc đó sẽ không còn cập nhật nào nữa và ta xem như xong.
So some properties, tying back to the question earlier. Separability is a property of your data. Your data is separable if you can find a hyperplane that separates it into the different classes.
Một vài tính chất, liên quan đến câu hỏi lúc nãy. Tính khả tách là một tính chất của dữ liệu. Dữ liệu khả tách nếu ta có thể tìm một siêu phẳng chia nó thành các lớp khác nhau.
Or if it's a multi-class problem, if there are weight vectors pointing in various directions, such that each can have their own region where all the data points from that class fall into that region, that's separable data.
Hoặc nếu là bài toán nhiều lớp, nếu có các vectơ trọng số chỉ theo nhiều hướng, sao cho mỗi lớp có vùng riêng của nó mà mọi điểm dữ liệu của lớp đó đều nằm trong vùng ấy, thì đó là dữ liệu khả tách.
Convergence is a property of a run of an algorithm. Your algorithm, when it is being run, could either converge or keep jumping around. Some algorithms will be guaranteed to always converge.
Sự hội tụ là tính chất của một lần chạy thuật toán. Khi thuật toán đang chạy, nó có thể hội tụ hoặc cứ nhảy lòng vòng. Một số thuật toán đảm bảo luôn hội tụ.
That's not true for the perceptron in general.
Với perceptron nói chung thì không đúng như vậy.
But if you have a binary perceptron with separable data, then it is guaranteed to converge, and it will find a decision boundary that separates the two classes.
Nhưng nếu là perceptron nhị phân với dữ liệu khả tách, thì nó đảm bảo hội tụ, và sẽ tìm được một ranh giới quyết định tách hai lớp ra.
How many mistakes can it make along the way? It can make at most this many mistakes. So we're not proving this guarantee, but let's get some intuition for this.
Trên đường đi nó có thể mắc bao nhiêu lỗi? Nó mắc nhiều nhất chừng này lỗi. Ta sẽ không chứng minh đảm bảo này, nhưng hãy lấy chút trực giác.
What is this saying?
Công thức này nói gì?
We have number of mistakes, we have k, which refers to the number of features that we have — so the size of the feature vector — and delta squared, where delta is the separability measure.
Ta có số lỗi, ta có k, là số đặc trưng mà ta có, tức là kích thước của vectơ đặc trưng, và delta bình phương, trong đó delta là độ đo khả tách.
So if you look at this data here, you can find the direction such that along this there is a separation of delta between the two classes. So that's delta.
Nếu nhìn dữ liệu này ở đây, ta có thể tìm một hướng sao cho dọc theo đó hai lớp cách nhau một khoảng delta. Đó là delta.
If you find this kind of separation that's non-zero between the two classical and parallel planes delta apart.
Nếu tìm được khoảng cách khác không như vậy giữa hai lớp, với hai mặt phẳng song song cách nhau delta.
If your data has non-zero delta, then this will be a finite number, assuming you have a finite number of features, and it means you'll make a finite number of mistakes after which you'll have converged.
Nếu dữ liệu có delta khác không, thì đây sẽ là một số hữu hạn, giả sử số đặc trưng là hữu hạn, nghĩa là ta mắc một số lỗi hữu hạn rồi sau đó thuật toán hội tụ.
Now, let's get some intuiton for this. This shows that the more features you have, the longer it might take before it converges, which makes sense.
Giờ hãy lấy thêm chút trực giác. Điều này cho thấy càng nhiều đặc trưng thì có thể càng lâu mới hội tụ, điều này hợp lý.
The more features you have, the more you need to learn to understand what these features tell you before you converge to the right decisions.
Càng nhiều đặc trưng thì càng phải học nhiều để hiểu các đặc trưng đó cho ta biết gì trước khi hội tụ về các quyết định đúng.
Also, the larger delta is, the less mistakes you're going to make. So the further your classes are apart, the easier the problem is and the less iterations you need to find a solution.
Ngoài ra, delta càng lớn thì càng ít lỗi. mà bạn sẽ thực hiện. Các lớp càng cách xa nhau thì bài toán càng dễ và càng cần ít vòng lặp để tìm ra lời giải.
So that's what this is saying over here.
Đó là điều công thức này nói ở đây.
Any questions about the positive properties? Yes.
Có câu hỏi nào về các tính chất tốt này không? Mời em.
STUDENT
[INAUDIBLE] PROFESSOR: We don't have the proof here so I can't justify it without working through the proof. I can't do it on the spot here.
[KHÔNG NGHE RÕ] GIÁO SƯ: Ở đây ta không có phần chứng minh nên tôi không thể giải thích nếu không làm lại phần chứng minh. Tôi không làm ngay tại chỗ được.
But if you were to work through the proof, it would tell you that it's strictly less than, unless you made a typo.
Nhưng nếu em làm theo phần chứng minh, nó sẽ cho thấy là nhỏ hơn hẳn, trừ khi em gõ nhầm.
Now, there are some problems. Often, your data will not be perfectly separable. Just like when you run linear regression, your data points don't necessarily all fit on a line.
Bây giờ có một số vấn đề. Thường thì dữ liệu sẽ không khả tách hoàn hảo. Giống như khi chạy hồi quy tuyến tính, các điểm dữ liệu không nhất thiết nằm hết trên một đường thẳng.
They might deviate from that line, and you might still want to run linear regression. Same thing here.
Chúng có thể lệch khỏi đường đó, mà ta vẫn muốn chạy hồi quy tuyến tính. Ở đây cũng vậy.
Even if your data is not perfectly separable, you might still want to find something that is a pretty good decision boundary that is usually correct.
Kể cả khi dữ liệu không khả tách hoàn hảo, ta vẫn có thể muốn tìm một ranh giới quyết định khá tốt và thường đúng.
So what to do then? Perceptron will just keep bouncing around. A new data point comes in, corrects for that, but then does another one wrong. Next time it has to correct for that one.
Vậy phải làm sao? Perceptron sẽ cứ nhảy lòng vòng. Một điểm dữ liệu mới đến, nó sửa cho điểm đó, nhưng lại làm sai một điểm khác. Lần sau nó lại phải sửa cho điểm kia.
And it just keeps happening over and over and over. Another thing that can happen is that you stop when you don't want to stop. Imagine you end up finding this decision boundary over here.
Và chuyện này cứ lặp đi lặp lại mãi. Một vấn đề khác là nó có thể dừng vào lúc ta không muốn dừng. Hãy tưởng tượng ta tìm ra ranh giới quyết định này ở đây.
Yeah. Everything's separated, but that's not a very smart decision, because there are some data points very close to that decision boundary.
Vâng. Mọi thứ đã được tách ra, nhưng đó không phải là quyết định thông minh, vì có một số điểm dữ liệu nằm rất gần đường biên quyết định đó.
And that means, well, what if a data point now actually is right over here? Wouldn't you prefer that one to be also blue when it classifies because it's closer to the blue ones?
Và điều đó có nghĩa là, nếu có một điểm dữ liệu nằm ngay ở đây thì sao? Chẳng phải bạn muốn điểm đó cũng được phân loại là xanh vì nó gần các điểm xanh hơn sao?
But with that decision boundary on top, it would actually classify it as red because it stopped. It found something where it doesn't make mistakes anymore.
Nhưng với đường biên quyết định ở trên kia, nó sẽ phân loại điểm này là đỏ, vì thuật toán đã dừng lại. Nó đã tìm được đường không còn mắc lỗi nào nữa.
So how to make it be a little more wary about being close to making mistakes and maybe shifting that boundary over a bit. That would be nice if you could do that.
Vậy làm sao để nó thận trọng hơn một chút khi đang ở gần ranh giới mắc lỗi, và có thể dịch đường biên đó đi một chút. Sẽ rất tốt nếu làm được như vậy.
Another issue, which you've already seen with naive Bayes, is that you could have overfitting. That one's actually not too hard to fix.
Một vấn đề khác, mà các em đã thấy với naive Bayes, là có thể xảy ra quá khớp. Vấn đề này khá dễ khắc phục.
So as you iterate, meaning you loop through your training data, you keep updating your weight vectors.
Khi bạn lặp, tức là duyệt qua dữ liệu huấn luyện, bạn liên tục cập nhật các vectơ trọng số.
Your training accuracy will keep going up because you're looking at your training data and it's telling you what to change to be more accurate on your training data.
Độ chính xác trên tập huấn luyện sẽ tăng dần vì bạn đang nhìn vào dữ liệu huấn luyện và nó cho bạn biết cần thay đổi gì để chính xác hơn trên dữ liệu huấn luyện.
But you'll have a separate stash of data, called hold out data, and another separate stash of data, called test data. The test data you can't touch.
Nhưng bạn sẽ có một phần dữ liệu riêng gọi là hold out data, và một phần dữ liệu riêng khác gọi là dữ liệu kiểm tra. Dữ liệu kiểm tra thì không được đụng vào.
That's for when you're 100% done you report out on. So it's representative of data you'll see in the future.
Chỉ khi làm xong hoàn toàn bạn mới báo cáo kết quả trên đó. Nó đại diện cho dữ liệu bạn sẽ gặp trong tương lai.
But your hold out data you use during training to monitor your training and see what's happening.
Còn hold out data thì bạn dùng trong lúc huấn luyện để theo dõi quá trình huấn luyện và xem chuyện gì đang xảy ra.
So as you're training you'll see on your hold out data accuracy will keep going up too for a while, but then it'll start saturating and go back down.
Khi huấn luyện, bạn sẽ thấy độ chính xác trên hold out data cũng tăng lên trong một thời gian, rồi bắt đầu bão hòa và giảm xuống.
And you want to stop training right here.
Và bạn muốn dừng huấn luyện ngay tại đây.
Once this starts going down again, that's the moment your updates are overfitting — that is, memorizing your training data — rather than fitting to the general pattern that you want to capture.
Khi nó bắt đầu giảm trở lại, đó là lúc các bản cập nhật gây quá khớp, tức là học thuộc lòng dữ liệu huấn luyện thay vì khớp với quy luật chung mà bạn muốn nắm bắt.
If you stop there, then you'd hope, since you used your hold out data only for this one thing — you only use it to decide where to stop — that very likely whatever you had on your hold out data is pretty representative of what you'll also get on your test data.
Nếu dừng ở đó, thì bạn có thể hy vọng, vì bạn chỉ dùng hold out data cho đúng một việc, là quyết định khi nào dừng, nên rất có thể kết quả trên hold out data khá đại diện cho kết quả bạn sẽ nhận được trên dữ liệu kiểm tra.
So this one's easily fixable. Early stopping. You stop training when you see hold out accuracy go down. How about the first two?
Vậy vấn đề này dễ sửa. Dừng sớm (early stopping). Bạn dừng huấn luyện khi thấy độ chính xác trên hold out data giảm. Còn hai vấn đề đầu thì sao?
How do we deal with those? Well, let's improve the perceptron and look at a new algorithm called logistic regression that will resolve those two issues.
Ta xử lý chúng thế nào? Ta hãy cải tiến perceptron và xem một thuật toán mới là hồi quy logistic, giải quyết được hai vấn đề đó.
Let's get some intuition first. So let's say we have data, blue and red, and we want to separate it. Red crosses, blue circles.
Trước hết ta xây dựng trực giác. Giả sử ta có dữ liệu xanh và đỏ, và ta muốn tách chúng ra. Dấu chéo đỏ, hình tròn xanh.
But these data is not separable so there's no perfect decision boundary here if we have to use a line. You might say, well, maybe you want to use not a line.
Nhưng dữ liệu này không tách được, nên không có đường biên quyết định hoàn hảo nếu ta phải dùng một đường thẳng. Bạn có thể nói, có lẽ đừng dùng đường thẳng.
Maybe you want to use some decision boundary that looks more squiggly, like this? That might be OK in some situations.
Có thể dùng một đường biên quyết định ngoằn ngoèo hơn, như thế này? Trong một số tình huống thì cũng được.
But you might argue also that this would be overfitting, that you don't really want to loop through in detail.
Nhưng bạn cũng có thể lập luận rằng đó là quá khớp, và bạn không thực sự muốn bám theo từng chi tiết như vậy.
And in general, it'll always be the case that if you get perfect score in your training data by making your things squiggly enough, it's unlikely to do well on your test data.
Nói chung, luôn luôn là như vậy: nếu bạn đạt điểm hoàn hảo trên dữ liệu huấn luyện bằng cách làm đường biên đủ ngoằn ngoèo, thì khó mà tốt trên dữ liệu kiểm tra.
So it's likely that altering your training data, you're not going to get 100%. So here's a scenario. We want to separate this by a line. It's not separable.
Nên nhiều khả năng với dữ liệu huấn luyện như vậy, bạn sẽ không đạt 100%. Đây là một tình huống. Ta muốn tách dữ liệu này bằng một đường thẳng. Nó không tách được.
What will your perceptron do? It'll keep bouncing back and forth between different decision boundaries and never converge. What if we think about the problem a little differently?
Perceptron sẽ làm gì? Nó sẽ cứ nhảy qua lại giữa các đường biên quyết định khác nhau và không bao giờ hội tụ. Nếu ta nghĩ về bài toán theo cách hơi khác thì sao?
Instead of thinking of it as one side is positive, the other side is negative, what if we think of it more gradually? We make a probabilistic decision?
Thay vì coi một phía là dương, phía kia là âm, ta thử nghĩ theo kiểu chuyển dần dần? Ta đưa ra quyết định theo xác suất?
So maybe we say on the line it's 50/50 because that's the decision boundary. That's where we don't know what it is.
Chẳng hạn trên đường thẳng là 50/50, vì đó là đường biên quyết định. Đó là nơi ta không biết nó thuộc lớp nào.
And then as we move in one direction, the line is 70% blue, 30% red. In the other direction, it might be 70/30 the other way around.
Rồi khi di chuyển theo một hướng, đường đó là 70% xanh, 30% đỏ. Theo hướng kia, có thể là 70/30 theo chiều ngược lại.
If we move further away from the decision boundary it becomes 90/10. Another direction further away becomes 90/10 the other way. If you think about it this way, it becomes a lot more meaningful.
Nếu ta đi xa hơn khỏi đường biên quyết định thì nó thành 90/10. Xa hơn theo hướng kia thì thành 90/10 theo chiều ngược lại. Nếu nghĩ theo cách này thì nó có ý nghĩa hơn nhiều.
It seems somehow more OK that you have still a red one here. You assigned a non-zero probability to having a red one there.
Có vẻ chấp nhận được hơn khi vẫn còn một điểm đỏ ở đây. Bạn đã gán một xác suất khác không cho việc có một điểm đỏ ở đó.
You're modeling the fact that sometimes something might lie on the wrong side of the decision boundary.
Bạn đang mô hình hóa việc đôi khi một điểm có thể nằm sai phía của đường biên quyết định.
And you could then decide, OK, if I make decisions this way, what's the best way to position this thing such that it reflects what's in my training data?
Và khi đó bạn có thể quyết định, nếu tôi ra quyết định theo cách này, thì cách tốt nhất để đặt đường này là gì để nó phản ánh đúng dữ liệu huấn luyện của tôi?
And you could hope for — and we'll see that you can actually position this in a way that you converge.
Và bạn có thể hy vọng, và ta sẽ thấy là thực sự có thể đặt nó theo cách hội tụ.
After you cycle to your data enough, this will be positioned in a stable way, and you won't want to move it anymore because you can't improve upon the positioning you found.
Sau khi duyệt dữ liệu đủ nhiều lần, đường này sẽ được đặt ở vị trí ổn định, và bạn sẽ không muốn dịch chuyển nó nữa vì không thể cải thiện thêm vị trí đã tìm được.
So how do we make this probabilistic? Perceptron scores with an inner product, w inner product with f of x. We'll call that z.
Vậy làm sao để biến nó thành xác suất? Perceptron cho điểm bằng tích vô hướng của w với f của x. Ta gọi đó là z.
z can be any number from negative infinity to all the way positive infinity. How do we make that a probability? Well, if it's very positive, we want it to be close to 1.
z có thể là bất kỳ số nào từ âm vô cực đến tận dương vô cực. Làm sao biến nó thành một xác suất? Nếu nó rất dương, ta muốn nó gần 1.
If it's very negative, we want it to be close to 0.
Nếu nó rất âm, ta muốn nó gần 0.
So can we find the function that turns what lies on the real line into something that lies between 0 and 1 with these properties?
Vậy ta có thể tìm một hàm biến một giá trị trên trục số thực thành giá trị nằm giữa 0 và 1 với những tính chất này không?
Because if we can, then we're kind of getting close to what we want to do here. Sigmoid function is a function that does this. What's a sigmoid function?
Vì nếu được, thì ta đã tiến gần đến điều mình muốn làm ở đây. Hàm sigmoid là hàm làm được điều này. Hàm sigmoid là gì?
It's 1 over 1 plus e to the negative z. If you draw that function, this is what it looks like. So when z's very negative, you're at roughly 0.
Nó bằng 1 chia cho 1 cộng e mũ âm z. Nếu vẽ hàm đó ra, nó trông như thế này. Khi z rất âm, giá trị xấp xỉ 0.
Then when z becomes closer to 0, this goes up through, and at positive infinity, it's at 1. So you gradual transition from 0 to 1 as z goes from negative infinity to positive infinity.
Khi z tiến gần về 0, đồ thị đi lên, và ở dương vô cùng thì giá trị là 1. Vậy nó chuyển dần từ 0 sang 1 khi z đi từ âm vô cùng đến dương vô cùng.
So this satisfies these properties over here.
Như vậy nó thỏa mãn các tính chất ở đây.
So what we could do in principle, going back to this drawing that we just had, if we had a weight vector, w — and let's say the positive class is that way so weight vector would be pointing that way — we could say, well, if weight times feature vector is positive it's on that side.
Về nguyên tắc, ta có thể quay lại hình vẽ lúc nãy, nếu có một vectơ trọng số w, và giả sử lớp dương nằm về phía kia, thì vectơ trọng số sẽ hướng về phía đó, ta có thể nói: nếu trọng số nhân vectơ đặc trưng là dương thì điểm nằm ở phía này.
The further we go that way, the closer our z, after taking a sigmoid, becomes a 1.
Càng đi về hướng đó, z của ta sau khi qua sigmoid càng gần 1.
And the more we go in the opposite direction, the closer we go to negative affinity with our activation z, and the closer we get to 0 for the positive class.
Và càng đi theo hướng ngược lại, giá trị kích hoạt z càng tiến về âm vô cùng, và xác suất của lớp dương càng gần 0.
So we have the mechanism to do this now. What's the best choice of w? Well, we've actually seen this kind of methodology in last lecture. We're now making probabilistic decisions.
Vậy giờ ta đã có cơ chế để làm việc này. Chọn w thế nào là tốt nhất? Thực ra ta đã thấy phương pháp này ở bài giảng trước. Giờ ta đang đưa ra các quyết định xác suất.
When we make probabilistic decisions, there is a common framework you can use to find good parameter vectors. It's the maximum likelihood framework.
Khi đưa ra quyết định xác suất, có một khuôn khổ chung có thể dùng để tìm vectơ tham số tốt. Đó là khuôn khổ maximum likelihood.
It tells you, I have my data, and I want to maximize the likelihood of the data. And the primary vector that does that is the one we choose.
Nó nói rằng: tôi có dữ liệu, và tôi muốn cực đại hóa likelihood của dữ liệu. Vectơ tham số nào làm được điều đó thì ta chọn.
So maximum likelihood. But now the likelihood will be focused on the decision we're making.
Đó là maximum likelihood. Nhưng giờ likelihood sẽ tập trung vào quyết định mà ta đang đưa ra.
So we want to maximize the sum of the log probabilities of the label given x or the features that are a function of x.
Ta muốn cực đại hóa tổng log xác suất của nhãn khi biết x, hay các đặc trưng là hàm của x.
What you saw in the last lecture was something along the lines of sum over i log probability of xi and yi under some parameterization w.
Bài trước các bạn thấy một thứ đại loại là tổng theo i của log xác suất của xi và yi dưới một tham số hóa w nào đó.
So if you look at that, that would have been sum over i log probability of yi given xi under w plus the log probability of just xi under w.
Nếu nhìn vào đó, nó sẽ là tổng theo i của log xác suất của yi khi biết xi dưới w, cộng log xác suất của riêng xi dưới w.
So we saw last lecture was trying to optimize both for modeling your x's and for modeling y given x all in one optimization. And what we're doing here, we're dropping this part.
Vậy bài trước ta cố gắng tối ưu đồng thời cho việc mô hình hóa x và mô hình hóa y khi biết x, tất cả trong một lần tối ưu. Còn ở đây, ta bỏ phần này đi.
We're saying, well, we don't care about w paying attention to get it right, like what's the distribution over x's, because we don't care about the distribution over x's.
Ta nói rằng, ta không cần w phải chú ý đến việc mô hình đúng phân phối của x, vì ta không quan tâm phân phối của x.
We care about making decisions. We want to know, what is y given an x?
Ta quan tâm đến việc đưa ra quyết định. Ta muốn biết y là gì khi biết x.
And we're going to focus on that part and optimize our parameters to be maximally good at predicting y given x and not make a trade-off with anything else that we might not care about.
Ta sẽ tập trung vào phần đó và tối ưu tham số để dự đoán y khi biết x thật tốt, mà không phải đánh đổi với bất cứ thứ gì khác mà ta có thể không quan tâm.
So what are these probabilities that we have here? Well, those are using the sigmoid. So the probability of a positive label is this thing over here.
Vậy những xác suất này là gì? Chúng dùng hàm sigmoid. Xác suất của nhãn dương là biểu thức này.
So it's, again, the 1 over 1 plus e to the negative z where, again, this thing here is z, which is w inner product with f of x.
Lại là 1 chia cho 1 cộng e mũ âm z, trong đó z ở đây là tích vô hướng của w với f của x.
And then the probability of the other label is, of course, 1 minus the probability of the first label. Once we fill this into this we have an objective.
Còn xác suất của nhãn kia dĩ nhiên là 1 trừ xác suất của nhãn đầu. Thay vào, ta có một hàm mục tiêu.
We can evaluate. This for any choice of w you can compute, what is my log likelihood of labels given inputs under this vector w?
Ta có thể tính nó. Với bất kỳ w nào, bạn có thể tính log likelihood của các nhãn khi biết đầu vào dưới vectơ w này.
And you can then, if you have extreme amount of compute, cycle over all infinitely many w's that exist, find the one that maximizes this, and choose that one.
Nếu có sức tính toán cực lớn, bạn có thể duyệt qua vô hạn các w đang tồn tại, tìm w cực đại hóa nó, rồi chọn w đó.
Or if you're lucky, you can take a derivative, like you did in last lecture, and find the one that [INAUDIBLE] equal to 0 and just analytically know which one it's going to be.
Hoặc nếu may mắn, bạn lấy đạo hàm như bài trước, và tìm w làm đạo hàm bằng 0 và biết ngay bằng giải tích w đó là gì.
What we're seeing here, taking the derivative, it's not going to give us a nice expression. We'll look at that next lecture what we can do to find this w.
Ở đây, lấy đạo hàm sẽ không cho ra biểu thức đẹp. Bài sau ta sẽ xem cách tìm w này.
But for now, just think about it as if you had infinite compute, you could cycle over all of them and pick the one that maximizes this. And that's the one we want to use.
Còn bây giờ, cứ nghĩ như thể bạn có sức tính toán vô hạn, bạn duyệt qua tất cả và chọn w cực đại hóa biểu thức này. Đó là w ta muốn dùng.
That's logistic regression.
Đó là hồi quy logistic.
What it also does, if you have many options — for example, here, same data set, but two decision boundaries that both separate the data perfectly — you might say this one is better because it takes more margin from the data points.
Nó còn làm được điều này, nếu bạn có nhiều lựa chọn, ví dụ ở đây, cùng một tập dữ liệu nhưng có hai ranh giới quyết định đều phân tách dữ liệu hoàn hảo, bạn có thể nói ranh giới này tốt hơn vì nó chừa nhiều lề hơn so với các điểm dữ liệu.
Perceptron won't care. Whichever one you feed it, it will say, I'm converged. I'm not doing any more updates. With the logistic regression formulation you're assigning probabilities.
Perceptron thì không quan tâm. Đưa cái nào vào nó cũng bảo: tôi hội tụ rồi. Tôi không cập nhật nữa. Với công thức hồi quy logistic, bạn gán xác suất.
And if you assign a 50/50 where there is actually a data point here and here, that's not a great decision. That will be a low log likelihood score that you'd get as a result.
Và nếu bạn gán 50/50 ở nơi thực ra có một điểm dữ liệu ở đây và ở đây, đó không phải quyết định tốt. Kết quả là bạn sẽ có điểm log likelihood thấp.
Whereas if your data points are further from the decision boundary, you'll be more confident about them. You will get higher log likelihoods.
Ngược lại, nếu các điểm dữ liệu ở xa hơn ranh giới quyết định, bạn sẽ tự tin hơn về chúng. Bạn sẽ có log likelihood cao hơn.
And so this one here will be preferred if you use this scoring mechanism.
Vì thế ranh giới này sẽ được ưu tiên nếu bạn dùng cơ chế chấm điểm này.
And so if you use logistic regression, you'll end up with this decision boundary on the left rather than one on the right, or being indifferent between them like perceptron would be.
Nên nếu dùng hồi quy logistic, bạn sẽ có ranh giới quyết định bên trái thay vì bên phải, hoặc thờ ơ giữa hai cái như perceptron.
OK.
OK.
So it's solved, in some sense, the two issues we had with perceptron — the notion of bouncing around when things are not separable by making it probabilistic, and it now has preferences in terms of wanting to put the decision boundary away from where the data points are so the log probabilities of a label given the data point are high.
Vậy theo một nghĩa nào đó, ta đã giải quyết hai vấn đề của perceptron: việc dao động khi dữ liệu không thể phân tách, nhờ làm cho nó mang tính xác suất, và giờ nó có sự ưu tiên, muốn đặt ranh giới quyết định tránh xa các điểm dữ liệu để log xác suất của nhãn khi biết đầu vào được cao. của điểm dữ liệu đều cao.
We generalize it to multiple classes. Well, perceptron had a weight vector for each class. We would score by wy.
Ta tổng quát hóa nó cho nhiều lớp. Perceptron có một vectơ trọng số cho mỗi lớp. Ta tính điểm bằng wy.
The weight vector for class y inner producted with f of x, the feature vector that we're considering now. We see which one has the highest score, and that's the one we decide for.
Vectơ trọng số của lớp y nhân vô hướng với f của x, vectơ đặc trưng mà ta đang xét. Ta xem lớp nào có điểm cao nhất, và ta chọn lớp đó.
Now, again, if the data is not separable, meaning you can't nicely compartmentalize in this plane according to three directions, then updates to the perceptron weights will keep going and going and going and never stop.
Giờ, nếu dữ liệu không phân tách được, nghĩa là bạn không thể chia gọn gàng trong mặt phẳng này theo ba hướng, thì các lần cập nhật trọng số perceptron sẽ cứ tiếp diễn mãi và không bao giờ dừng.
We can use the same idea. We can say, instead of having deterministic decision boundaries, what if we make it probabilistic?
Ta có thể dùng cùng ý tưởng. Thay vì có ranh giới quyết định tất định, nếu ta làm nó mang tính xác suất thì sao?
We're OK with a region being 90% label one and 10% maybe label two, or 90% level two, 5% label three, 5% label one. We're OK with that.
Ta chấp nhận một vùng là 90% nhãn một và 10% có thể là nhãn hai, hoặc 90% nhãn hai, 5% nhãn ba, 5% nhãn một. Ta chấp nhận điều đó.
Well, then we can do the same thing. But how do we get this probabilities? Let's say we have some scores, z1, z2, z3. This one will be from negative infinity to positive infinity.
Vậy thì ta có thể làm tương tự. Nhưng làm sao có được các xác suất này? Giả sử ta có các điểm số z1, z2, z3. Số này nằm từ âm vô cùng đến dương vô cùng.
This one also. This one also. We want to turn out into numbers between 0 and 1 where, if you have a very high score, close to positive infinity, you're close to 1.
Số này cũng vậy. Số này cũng vậy. Ta muốn biến chúng thành các số giữa 0 và 1 sao cho điểm rất cao, gần dương vô cùng, thì gần 1.
If you have a very low score close to negative infinity, you want to be close to 0. This is a calculation that will do this for you. Let's look at this.
Điểm rất thấp, gần âm vô cùng, thì gần 0. Có một phép tính làm được điều này. Hãy xem nó.
Let's look at the first one. Let's say I'm going to exponentiate the number z1. What does exponentiating do? z1 lives here. e to the z1 lives here.
Xét số đầu tiên. Giả sử ta lấy mũ số z1. Lấy mũ làm gì? z1 nằm ở đây. e mũ z1 nằm ở đây.
It's a curve that looks like that and grows pretty quickly, actually, as you move further to the right. So this will always return a positive number.
Đó là một đường cong trông như thế này và tăng khá nhanh khi ta đi xa hơn về bên phải. Nên nó luôn trả về một số dương.
So one thing we can already see is, then, all three numbers we generate — the e to the z1, e to the z2, e to the z3 — will be positive numbers.
Vậy ta đã thấy một điều: cả ba số tạo ra, e mũ z1, e mũ z2, e mũ z3, đều là số dương.
The three that we end up with combined will sum to 1, because there's e to the z1, e to the z2, e to the z3, and we divide by the sum.
Ba số cuối cùng cộng lại sẽ bằng 1, vì ta có e mũ z1, e mũ z2, e mũ z3, rồi chia cho tổng.
So that's guaranteed to sum to 1. So we've turned our original numbers, whether they're positive or negative, into three positive numbers that sum to 1. So we have a probability distribution.
Nên chắc chắn tổng bằng 1. Vậy ta đã biến các số ban đầu, dù dương hay âm, thành ba số dương có tổng bằng 1. Tức là ta có một phân phối xác suất.
Doesn't have the properties we want. The more you're out to the right, the more you're positive, the higher your e to the z will be and it'll grow very quickly.
Và nó có các tính chất ta muốn. Càng nằm về bên phải, càng dương thì e mũ z càng cao và tăng rất nhanh.
And so you'll have a higher score up here if z1 is very high. But it's all relative. It all depends on where z2 and z3 are.
Nên bạn sẽ có điểm cao hơn ở trên đây nếu z1 rất cao. Nhưng tất cả mang tính tương đối. Nó phụ thuộc vào vị trí của z2 và z3.
Whichever one is the highest will dominate this calculation. Why is that? Because we know exponentials grow very quickly.
Số nào cao nhất sẽ chi phối phép tính này. Tại sao vậy? Vì ta biết hàm mũ tăng rất nhanh.
And so if z2 is a bit higher than z2, then e to the z1 will be quite a bit higher than e to the z2, and it'll dominate the probabilities here.
Nên nếu z1 cao hơn z2 một chút thì e mũ z1 sẽ cao hơn e mũ z2 khá nhiều, và nó sẽ chi phối các xác suất ở đây.
If they're equal, well, then they'll equal dominate. So we get the right kind of properties here. If you're higher than the others, you will have the highest probability.
Nếu chúng bằng nhau thì chúng chi phối ngang nhau. Vậy ta có đúng các tính chất cần thiết. Nếu bạn cao hơn các số khác, bạn sẽ có xác suất cao nhất.
If you're lower than the others, you'll have the lowest probability. If you're in the middle, you'll have the middle probability.
Nếu bạn thấp hơn các số khác, bạn sẽ có xác suất thấp nhất. Nếu ở giữa, bạn có xác suất ở giữa.
The numbers on the left are the original activations, and the ones on the right are called softmax activations. So our perceptron, in some sense, outputs just regular activations.
Các số bên trái là các activation ban đầu, còn các số bên phải gọi là softmax activation. Perceptron của ta, theo một nghĩa nào đó, chỉ xuất ra activation thông thường.
When we do multi-class logistic regression, we'll feed that through a softmax calculation which turns it into probabilities. Once we have probabilities, we, again, have a mechanism to optimize the parameters.
Khi làm hồi quy logistic đa lớp, ta đưa nó qua phép tính softmax, biến nó thành xác suất. Khi đã có xác suất, ta lại có cơ chế để tối ưu các tham số.
We can, again, do maximum likelihood estimation. We can say, OK, which w is the best w? Well, the best w is the one that maximizes the likelihood of the labels given the features.
Ta lại có thể dùng ước lượng hợp lý cực đại. Ta hỏi: w nào là w tốt nhất? Tốt nhất là w làm cực đại khả năng xảy ra của các nhãn cho trước các đặc trưng.
So that's this quantity over here. I sum over all data points. I look at the log probability of the label given the input vector under a choice of parameter vector w.
Đó chính là đại lượng này. Tôi lấy tổng trên mọi điểm dữ liệu. Tôi xét log xác suất của nhãn cho trước vectơ đầu vào với một lựa chọn vectơ tham số w.
And the one that we conclude is best is among all infinitely many choices of w the one that maximizes this. Again, this is very similar to what you covered with naive Bayes.
Và w ta kết luận là tốt nhất trong vô số lựa chọn w là w làm cực đại đại lượng này. Điều này rất giống với những gì các bạn đã học ở naive Bayes.
But the difference is that we directly focus on this conditional distribution.
Nhưng khác ở chỗ ta trực tiếp tập trung vào phân phối có điều kiện này.
In naive Bayes you looked at sum over i log pyi comma xi under your parameter vector w, which is sum over i log pyi given xi under w
Ở naive Bayes, bạn xét tổng theo i log p của yi phẩy xi với vectơ tham số w, bằng tổng theo i log p của yi cho trước xi với w
plus log probability xi under w.
cộng log xác suất của xi với w.
The difference in terminology here that's often used, what we're looking at today, is called discriminative classification.
Về thuật ngữ, người ta thường dùng khác nhau, những gì ta xét hôm nay gọi là phân loại phân biệt (discriminative).
A discriminative approach which focus on discriminating the points — do they belong to one label or another label? — focus on just this first term here, whereas what we covered in the last lecture is called generative models.
Cách tiếp cận discriminative tập trung vào việc phân biệt các điểm dữ liệu: chúng thuộc nhãn này hay nhãn kia? chỉ tập trung vào số hạng đầu tiên ở đây, còn những gì ta học ở bài trước gọi là mô hình sinh (generative).
They learn how to generate all of the data, and then after the fact might do a calculation to discriminate. But they're trained to generate and might after fact be reused to discriminate.
Chúng học cách sinh ra toàn bộ dữ liệu, rồi sau đó có thể tính toán để phân biệt. Nhưng chúng được huấn luyện để sinh, và sau đó có thể được dùng lại để phân biệt.
Again, why might you prefer what we're doing today? Because if you learn a generative model, you pay attention to two terms.
Vậy vì sao bạn có thể thích cách làm hôm nay hơn? Vì nếu học một mô hình sinh, bạn phải chú ý đến hai số hạng.
And if ultimately all you care about is the first term, why would you let your choice of w be influenced by the second term if the first term is what matters?
Và nếu cuối cùng điều bạn quan tâm là số hạng thứ nhất, thì tại sao lại để việc chọn w bị ảnh hưởng bởi số hạng thứ hai, trong khi số hạng thứ nhất mới là điều quan trọng?
Now you might also wonder, would anybody ever use the generative approach? Well, it turns out that having this second term can somehow regularize at times.
Các em cũng có thể thắc mắc: liệu có ai dùng cách tiếp cận generative không? Thực ra, có số hạng thứ hai này đôi khi có thể đóng vai trò regularize.
So there are scenarios where having that second term can kind of moderate your choice of w in some way that makes it somehow better in not overfitting the data.
Có những trường hợp số hạng thứ hai đó giúp điều chỉnh việc chọn w theo cách nào đó giúp tốt hơn trong việc tránh quá khớp dữ liệu.
So there are some trade-offs there. Sometimes it might better to go one way, sometimes the other way.
Vậy nên có những đánh đổi ở đây. Có khi nên chọn cách này, có khi nên chọn cách kia.
If you have a very small amount of data, often having the second term can be good to make up for the fact you have a small amount of data.
Nếu bạn có rất ít dữ liệu, thì số hạng thứ hai thường hữu ích để bù lại việc dữ liệu ít.
If you have a very large amount of data, just focusing on the first term will allow you to focus on what you care about.
Nếu bạn có rất nhiều dữ liệu, thì chỉ tập trung vào số hạng thứ nhất cho phép bạn tập trung vào điều mình quan tâm.
And the data will be so much in that scenario that you don't care about any kind of moderation on w. You just want to get it right. You focus on that first term.
Và dữ liệu lúc đó nhiều đến mức bạn không cần điều chỉnh gì cho w nữa. Bạn chỉ muốn làm cho đúng. Bạn tập trung vào số hạng thứ nhất.
What does it look like underneath?
Bên dưới nó trông như thế nào?
Well, this here is the activation, z, for label y, for data point i.
Đây là activation, z, cho nhãn y, của điểm dữ liệu i.
And here we sum over all other possible labels that we could have. So this is the softmax that we just saw on this slide over here.
Và ở đây ta lấy tổng trên tất cả các nhãn khác có thể có. Đây chính là softmax mà ta vừa thấy trên slide ở bên kia.
It's now just written out with the z's as inner products of w's and features. So that's what we have here.
Giờ nó được viết ra với các z là tích vô hướng của các w và các đặc trưng. Đó là những gì ta có ở đây.
So this is multi class logistic regression.
Đây là hồi quy logistic đa lớp.
Once we use this we will not have the issues anymore of bouncing around or stopping when we're still close to some data points and we could grab a better margin by keep training.
Một khi dùng cái này, ta sẽ không còn gặp vấn đề dao động qua lại hay dừng lại khi vẫn còn gần một số điểm dữ liệu, trong khi có thể đạt margin tốt hơn nếu tiếp tục huấn luyện.
This will automatically find the better margins and will automatically still converge, even when the data is not separable. Next lecture we'll look at how we solve this.
Cái này sẽ tự động tìm ra margin tốt hơn và vẫn tự động hội tụ, ngay cả khi dữ liệu không phân tách được. Bài sau ta sẽ xem cách giải bài toán này.
So so far I've told you, well, we have a definition of what it means to be the best w.
Cho đến giờ, thầy mới nói rằng ta có định nghĩa thế nào là w tốt nhất.
I have not told you how to find that best w, short of having infinite compute and checking all w's. But that's not practical because nobody has infinite compute.
Thầy chưa nói cách tìm w tốt nhất đó, ngoài việc có tính toán vô hạn rồi kiểm tra mọi w. Nhưng điều đó không thực tế vì không ai có tính toán vô hạn.
And so next lecture, we'll look at how we find this w in a reasonable amount of compute time, which we'll then be able to generalize to a lot of other problems too.
Vì vậy bài sau, ta sẽ xem cách tìm w này với lượng tính toán hợp lý, và sau đó ta có thể khái quát hóa cho rất nhiều bài toán khác nữa.
All right. That's it for today. I'll see you on Thursday.
Được rồi. Hôm nay đến đây thôi. Hẹn gặp các em vào thứ Năm.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.