Softmax exercise
Complete and hand in this completed worksheet (including its outputs and any supporting code outside of the worksheet) with your assignment submission. For more details see the assignments page on the course website.
This exercise is analogous to the SVM exercise. You will:
- implement a fully-vectorized loss function for the Softmax classifier
- implement the fully-vectorized expression for its analytic gradient
- check your implementation with numerical gradient
- use a validation set to tune the learning rate and regularization strength
- optimize the loss function with SGD
- visualize the final learned weights
和linear_svm一样,主要难点是求导操作,不过softmax的求导更简单一些。
首先还是给出 Loss 的公式:
其中共有 N 个样本,每个样本带来的 Loss 是
对于每一个样本 Xi , 由于 softmax 的分母对所有的 fj 进行了累积求和, 所以 Li 对 W 的导数对
当 j!=y