C1W1-10_logistic-regression-training

视频链接

In the previous video, you learned how to classify whether a tweet has a positive sentiment or negative sentiment, using a theta that I have give you. In this video, you will learn your own theta from scratch, and specifically, I’ll walk you through an algorithm that allows you to get your theta variable. Let’s see how you can do this. To train your logistc regression classifier, iterate until you find the set of parameters theta, that minimizes your cost function. Let us suppose that your loss only depends on the parameters theta1 and theta2, you would have a cost function that looks like this contour plots on the left. On the right, you can see the evolution of the cost function as you iterate. First, you would have to initialize your parameters theta. Then you will update your theta in the direction of the gradient of your cost function. After a 100 iterations, you would be at this point, after 200 here, and so on. After many iterations, you derive to a point near your optimum costs and you’d end your training here.

在先前的视频中,你学习了如何分类是否一个推文有一个积极情绪或是消极情绪,通过使用一个我给你的 θ \theta θ。在这个视频中,你将从零开始学习 θ \theta θ,具体的说,我将带你们通过一个算法来得到 θ \theta θ变量。让我们看看怎么做吧。为了训练你的逻辑回归分类器,迭代直到你发现一组参数 θ \theta θ,来使你的成本函数最小化。让我们假设你的损失仅取决于参数 θ 1 \theta_1 θ1 θ 2 \theta_2 θ2,你会有一个成本函数,就像左边的等高线图。在右边,你可以看到迭代过程中成本函数的变化。首先,你必须初始化你的参数 θ \theta θ。然后你就可以自代价函数的梯度方向上更新你的 θ \theta θ。在100次迭代之后,将是这个点,在这里200次迭代,等等。在许多次迭代之后,你获得一个跟你最优成本相近的点,你的训练在这里终止了。
C1W1-10_logistic-regression-training_第1张图片

Let’s look at this process in model detail. First, you’d have to initialize your parameters vector theta. Then you’d use the logistic function to get values for each of your observations. After that, you’d be able to calculate the gradients of your cost function and update your parameters. Finally, you’d be able to compute you cost J and determine if more iterations are needed according to a stop-parameter or maximum number of iterations. As you might have seen in the other courses, this algorithm is known as gradient descent.

让我们看下模型的详细过程。首先,你必须初始化你的参数向量 θ \theta θ。然后你使用逻辑函数来得到你的每一个观察值。接着,你能够计算你的成本函数梯度并更新你的参数。最后,你计算你的成本J,根据一个停止参数或迭代的最大值来确定是否需要更多的迭代。正如你在其他课程中看到的,这种算法被称为梯度下降法。
C1W1-10_logistic-regression-training_第2张图片

Now, that you have your theta variable, you want to evaluate your theta, meaning you want to evaluate your classifier. Once you put in your theta into your sigmoid function, do get a good classifier or do you get a bad classifier?

现在你有了你的 θ \theta θ变量,你想要计算你的 θ \theta θ,意味着你想要计算你的分类器。一旦你把 θ \theta θ放到你的sigmoid函数中,你能得到一个好的分类器还是一个差的分类器?

你可能感兴趣的:(nlp)