{"id":1608,"date":"2025-01-23T13:20:00","date_gmt":"2025-01-23T05:20:00","guid":{"rendered":"https:\/\/www.forillusion.com\/?p=1608"},"modified":"2025-02-14T11:39:02","modified_gmt":"2025-02-14T03:39:02","slug":"3-4-softmax-regression","status":"publish","type":"post","link":"https:\/\/www.forillusion.com\/index.php\/3-4-softmax-regression\/","title":{"rendered":"3.4 softmax\u56de\u5f52"},"content":{"rendered":"\n<p><div class=\"has-toc have-toc\"><\/div><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u7c7b\u95ee\u9898<\/h2>\n\n\n\n<p>\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u9002\u7528\u4e8e\u8f93\u51fa\u4e3a\u8fde\u7eed\u503c\u7684\u60c5\u666f\u3002softmax\u56de\u5f52\u9002\u7528\u4e8e\u79bb\u6563\u503c\u7684\u9884\u6d4b\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u901a\u5e38\u4f7f\u7528\u79bb\u6563\u7684\u6570\u503c\u6765\u8868\u793a\u7c7b\u522b\uff0c\u4f8b\u5982$y_1=1, y_2=2, y_3=3$\u3002\u4e0e\u7ebf\u6027\u56de\u5f52\u7684\u4e00\u4e2a\u4e3b\u8981\u4e0d\u540c\u5728\u4e8e\uff0csoftmax\u56de\u5f52\u7684\u8f93\u51fa\u503c\u4e2a\u6570\u7b49\u4e8e\u6807\u7b7e\u91cc\u7684\u7c7b\u522b\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">softmax\u56de\u5f52\u6a21\u578b<\/h2>\n\n\n\n<p>softmax\u56de\u5f52\u540c\u7ebf\u6027\u56de\u5f52\u4e00\u6837\uff0c\u4e5f\u662f\u4e00\u4e2a\u5355\u5c42\u795e\u7ecf\u7f51\u7edc\u3002\u8f93\u51fa\u503c$o_i$\u5f53\u4f5c\u9884\u6d4b\u7c7b\u522b\u662f$i$\u7684\u7f6e\u4fe1\u5ea6\u3002<\/p>\n\n\n\n<p>$$<br>\\hat{y}_1, \\hat{y}_2, \\hat{y}_3 = \\text{softmax}(o_1, o_2, o_3)<br>$$<\/p>\n\n\n\n<p>$$<br>\\hat{y}_1 = \\frac{ \\exp(o_1)}{\\sum_{i=1}^3 \\exp(o_i)},\\quad\\hat{y}_2 = \\frac{ \\exp(o_2)}{\\sum_{i=1}^3 \\exp(o_i)},\\quad\\hat{y}_3 = \\frac{ \\exp(o_3)}{\\sum_{i=1}^3 \\exp(o_i)}.<br>$$<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5355\u6837\u672c\u5206\u7c7b\u7684\u77e2\u91cf\u8ba1\u7b97\u8868\u8fbe\u5f0f<\/h2>\n\n\n\n<p>softmax\u56de\u5f52\u5bf9\u6837\u672c$i$\u5206\u7c7b\u7684\u77e2\u91cf\u8ba1\u7b97\u8868\u8fbe\u5f0f\u4e3a<\/p>\n\n\n\n<p>$$<br>\\begin{aligned}\\boldsymbol{o}^{(i)} &amp;= \\boldsymbol{x}^{(i)} \\boldsymbol{W} + \\boldsymbol{b},\\\\\\boldsymbol{\\hat{y}}^{(i)} &amp;= \\text{softmax}(\\boldsymbol{o}^{(i)})\\end{aligned}<br>$$<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570<\/h2>\n\n\n\n<p>\u5e73\u65b9\u635f\u5931\u5219\u8fc7\u4e8e\u4e25\u683c\uff0c\u4ea4\u53c9\u71b5\uff08cross entropy\uff09\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u8861\u91cf\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>$$<br>H\\left(\\boldsymbol y^{(i)}, \\boldsymbol {\\hat y}^{(i)}\\right ) = -\\sum_{j=1}^q y_j^{(i)} \\log \\hat y_j^{(i)},<br>$$<\/p>\n\n\n\n<p>\u5047\u8bbe\u8bad\u7ec3\u6570\u636e\u96c6\u7684\u6837\u672c\u6570\u4e3a$n$\uff0c\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u5b9a\u4e49\u4e3a<\/p>\n\n\n\n<p>$$<br>\\ell(\\boldsymbol{\\Theta}) = \\frac{1}{n} \\sum_{i=1}^n H\\left(\\boldsymbol y^{(i)}, \\boldsymbol {\\hat y}^{(i)}\\right ),<br>$$<\/p>\n\n\n\n<p>\u5176\u4e2d$\\boldsymbol{\\Theta}$\u4ee3\u8868\u6a21\u578b\u53c2\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u7c7b\u95ee\u9898 \u7ebf\u6027\u56de\u5f52\u6a21\u578b\u9002\u7528\u4e8e\u8f93\u51fa\u4e3a\u8fde\u7eed\u503c\u7684\u60c5\u666f\u3002softmax\u56de\u5f52\u9002\u7528\u4e8e\u79bb\u6563\u503c\u7684\u9884\u6d4b\u95ee\u9898\u3002 \u901a\u5e38\u4f7f\u7528\u79bb\u6563\u7684\u6570\u503c\u6765\u8868\u793a\u7c7b\u522b\uff0c\u4f8b\u5982$y &#8230;<\/p>","protected":false},"author":1,"featured_media":1626,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46,3],"tags":[45,44,12,22],"class_list":["post-1608","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-46","category-3","tag-45","tag-44","tag-12","tag-22"],"_links":{"self":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/comments?post=1608"}],"version-history":[{"count":1,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1608\/revisions"}],"predecessor-version":[{"id":1718,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1608\/revisions\/1718"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media\/1626"}],"wp:attachment":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media?parent=1608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/categories?post=1608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/tags?post=1608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}