Natural Language Processing · 免费预览

交叉熵损失上的梯度下降

来自条件最大似然的交叉熵损失、它在逻辑回归中的简洁梯度,以及随机梯度下降的实际应用。

1. Gradient Descent on the Cross-Entropy Loss

Gradient Descent on the Cross-Entropy Loss

2. Following the gradient downhill

Following the gradient downhill

3. Training a tiny sentiment classifier

Training a tiny sentiment classifier

4. One term of the cross-entropy loss

A classifier outputs y^=0.9\hat{y} = 0.9 and the gold label is y=0y = 0. Compute the cross-entropy loss LCE(y^,y)L_{\text{CE}}(\hat{y}, y) and round to three decimals.

5. The logistic gradient on one weight

During training, a document has feature value xj=5x_j = 5, the model outputs y^=0.7\hat{y} = 0.7, and the gold label is y=0y = 0. Compute ∂L∂wj=(y^−y) xj\frac{\partial L}{\partial w_j} = (\hat{y} - y)\,x_j and round to three decimals.

6. One SGD step

A weight starts at wj=1w_j = 1, the document's feature is xj=4x_j = 4, the model outputs y^=0.3\hat{y} = 0.3, the gold label is y=1y = 1, and the learning rate is η=0.1\eta = 0.1. After the SGD update wj←wj−η(y^−y)xjw_j \leftarrow w_j - \eta (\hat{y} - y) x_j, what is the new wjw_j? Round to three decimals.

7. Comparing gradient magnitudes

Both documents have the same feature value xj=3x_j = 3 and gold label y=0y = 0. Document A gets y^=0.1\hat{y} = 0.1 and document B gets y^=0.9\hat{y} = 0.9. Which weight update has the larger magnitude, and why?

8. Convexity, learning rates, and hyperparameters

Which statement about training logistic regression with gradient descent is correct?

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课