{"id":57217,"date":"2025-08-15T08:59:34","date_gmt":"2025-08-15T00:59:34","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57217.html"},"modified":"2025-08-15T08:59:34","modified_gmt":"2025-08-15T00:59:34","slug":"%e5%8a%a8%e6%89%8b%e5%ad%a6%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0%ef%bc%88pytorch%e7%89%88%ef%bc%89%ef%bc%9a%e7%ac%ac%e4%b8%89%e7%ab%a0%e8%8a%82-%e7%ba%bf%e6%80%a7%e7%a5%9e%e7%bb%8f%e7%bd%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57217.html","title":{"rendered":"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52"},"content":{"rendered":"<p>Softmax\u56de\u5f52\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u591a\u7c7b\u5206\u7c7b\u7b97\u6cd5&#xff0c;\u9002\u7528\u4e8e\u5c06\u8f93\u5165\u6570\u636e\u6620\u5c04\u5230\u591a\u4e2a\u79bb\u6563\u7c7b\u522b\u3002\u5b83\u662f\u903b\u8f91\u56de\u5f52\u7684\u6269\u5c55&#xff0c;\u5e38\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7b49\u9886\u57df\u3002\u5176\u6838\u5fc3\u662f\u901a\u8fc7softmax\u51fd\u6570\u5c06\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8f6c\u6362\u4e3a\u6982\u7387\u5206\u5e03&#xff0c;\u4ece\u800c\u9884\u6d4b\u6bcf\u4e2a\u7c7b\u522b\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<h2>1.\u00a0\u7b80\u4ecb\u4e0e\u76ee\u7684<\/h2>\n<p>Softmax\u56de\u5f52\u7684\u76ee\u6807\u662f\u89e3\u51b3\u591a\u7c7b\u5206\u7c7b\u95ee\u9898&#xff08;\u4f8b\u5982&#xff0c;\u5c06\u56fe\u50cf\u5206\u4e3a\u201c\u732b\u201d\u3001\u201c\u72d7\u201d\u6216\u201c\u9e1f\u201d&#xff09;\u3002\u7ed9\u5b9a\u8f93\u5165\u7279\u5f81\u5411\u91cf<img decoding=\"async\" alt=\"$x$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86742cbc6.png\" \/>&#xff0c;\u6a21\u578b\u8f93\u51fa\u4e00\u4e2a\u6982\u7387\u5411\u91cf<img decoding=\"async\" alt=\"$p$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86743c3b6.png\" \/>&#xff0c;\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20<img decoding=\"async\" alt=\"$p_i$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e867448480.png\" \/>\u8868\u793a\u8f93\u5165\u5c5e\u4e8e\u7b2c<img decoding=\"async\" alt=\"$i$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674532cd.png\" \/>\u4e2a\u7c7b\u522b\u7684\u6982\u7387\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6982\u7387\u603b\u548c\u4e3a1&#xff0c;\u5373 <img decoding=\"async\" alt=\"$\\\\sum_{i} p_i &#061; 1$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86745e835.png\" \/>\u3002\u8fd9\u4f7f\u5f97\u6a21\u578b\u80fd\u76f4\u89c2\u5730\u8868\u793a\u5206\u7c7b\u4e0d\u786e\u5b9a\u6027\u3002<\/p>\n<h2>2.\u00a0\u6570\u5b66\u57fa\u7840<\/h2>\n<p>Softmax\u56de\u5f52\u7684\u6838\u5fc3\u662fsoftmax\u51fd\u6570\u548c\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u3002<\/p>\n<ul>\n<li>\n<p>Softmax\u51fd\u6570&#xff1a;\u8be5\u51fd\u6570\u5c06\u7ebf\u6027\u6a21\u578b\u7684\u539f\u59cb\u8f93\u51fa&#xff08;\u79f0\u4e3alogits&#xff09;\u8f6c\u6362\u4e3a\u6982\u7387\u3002\u5047\u8bbe\u6709<img decoding=\"async\" alt=\"$K$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86746915c.png\" \/> \u4e2a\u7c7b\u522b&#xff0c;\u5bf9\u4e8e\u8f93\u5165 <img decoding=\"async\" alt=\"$x$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86742cbc6.png\" \/>&#xff0c;\u6a21\u578b\u9996\u5148\u8ba1\u7b97logits\u5411\u91cf <img decoding=\"async\" alt=\"$z$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e867473fd8.png\" \/>&#xff1a; <img decoding=\"async\" alt=\"$ z &#061; Wx &#043; b $\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86747e6d4.png\" \/>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li><img decoding=\"async\" alt=\"$W$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674891c6.png\" \/> \u662f\u6743\u91cd\u77e9\u9635&#xff08;\u7ef4\u5ea6\u4e3a <img decoding=\"async\" alt=\"$K \\\\times d$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e867493eb6.png\" \/>&#xff0c;<img decoding=\"async\" alt=\"$d$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674a1406.png\" \/>\u662f\u7279\u5f81\u7ef4\u5ea6&#xff09;&#xff0c;<\/li>\n<li><img decoding=\"async\" alt=\"$b$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674ad1d7.png\" \/>\u662f\u504f\u7f6e\u5411\u91cf&#xff08;\u7ef4\u5ea6\u4e3a <img decoding=\"async\" alt=\"$K \\\\times 1$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674b86f3.png\" \/>&#xff09;\u3002 \u7136\u540e&#xff0c;softmax\u51fd\u6570\u5c06<img decoding=\"async\" alt=\"$z$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e867473fd8.png\" \/> \u8f6c\u6362\u4e3a\u6982\u7387<img decoding=\"async\" alt=\"$p$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86743c3b6.png\" \/>&#xff1a; <img decoding=\"async\" alt=\"$ p_i &#061; \\\\frac{e^{z_i}}{\\\\sum_{j&#061;1}^{K} e^{z_j}} \\\\quad \\\\text{for} \\\\quad i &#061; 1, 2, \\\\ldots, K $\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674c5411.png\" \/>\u8fd9\u91cc&#xff0c;<img decoding=\"async\" alt=\"$e^{z_i}$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674d40ec.png\" \/>\u662f\u6307\u6570\u51fd\u6570&#xff0c;\u786e\u4fdd\u8f93\u51fa\u4e3a\u6b63\u6570&#xff0c;\u4e14\u5206\u6bcd\u5f52\u4e00\u5316\u4f7f\u6982\u7387\u548c\u4e3a1\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u635f\u5931\u51fd\u6570&#xff1a;\u4f7f\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u6765\u8861\u91cf\u9884\u6d4b\u6982\u7387 <img decoding=\"async\" alt=\"$p$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86743c3b6.png\" \/> \u4e0e\u771f\u5b9e\u6807\u7b7e<img decoding=\"async\" alt=\"$y$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674defae.png\" \/>&#xff08;one-hot\u7f16\u7801&#xff09;\u7684\u5dee\u5f02\u3002\u635f\u5931\u51fd\u6570\u5b9a\u4e49\u4e3a&#xff1a; <img decoding=\"async\" alt=\"$ L &#061; -\\\\sum_{i&#061;1}^{K} y_i \\\\log(p_i) $\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674e9ac5.png\" \/>\u00a0\u5176\u4e2d <img decoding=\"async\" alt=\"$y_i$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005933-689e867503e84.png\" \/> \u662f\u771f\u5b9e\u6807\u7b7e\u7684\u7b2c<img decoding=\"async\" alt=\"$i$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674532cd.png\" \/> \u4e2a\u5143\u7d20&#xff08;\u5982\u679c\u7c7b\u522b\u6b63\u786e\u5219\u4e3a1&#xff0c;\u5426\u5219\u4e3a0&#xff09;\u3002\u6700\u5c0f\u5316\u8be5\u635f\u5931\u53ef\u4f18\u5316\u6a21\u578b\u53c2\u6570\u3002<\/p>\n<\/li>\n<\/ul>\n<h2>3.\u00a0\u8bad\u7ec3\u8fc7\u7a0b<\/h2>\n<p>\u8bad\u7ec3Softmax\u56de\u5f52\u6d89\u53ca\u4f18\u5316\u53c2\u6570<img decoding=\"async\" alt=\"$W$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674891c6.png\" \/>\u548c <img decoding=\"async\" alt=\"$b$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674ad1d7.png\" \/> \u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570<img decoding=\"async\" alt=\"$L$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005933-689e86750fd01.png\" \/>\u3002\u5e38\u7528\u65b9\u6cd5\u662f\u68af\u5ea6\u4e0b\u964d&#xff1a;<\/p>\n<li>\u521d\u59cb\u5316\u53c2\u6570&#xff1a;\u968f\u673a\u8bbe\u7f6e <img decoding=\"async\" alt=\"$W$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674891c6.png\" \/> \u548c <img decoding=\"async\" alt=\"$b$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674ad1d7.png\" \/>\u3002<\/li>\n<li>\u524d\u5411\u4f20\u64ad&#xff1a;\u5bf9\u6bcf\u4e2a\u8f93\u5165<img decoding=\"async\" alt=\"$x$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86742cbc6.png\" \/>\u8ba1\u7b97 <img decoding=\"async\" alt=\"$z &#061; Wx &#043; b$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005933-689e86751d487.png\" \/>&#xff0c;\u7136\u540e\u5e94\u7528softmax\u5f97\u5230<img decoding=\"async\" alt=\"$p$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86743c3b6.png\" \/>\u3002<\/li>\n<li>\u8ba1\u7b97\u68af\u5ea6&#xff1a;\u4f7f\u7528\u94fe\u5f0f\u6cd5\u5219\u8ba1\u7b97\u635f\u5931\u5bf9\u53c2\u6570\u7684\u68af\u5ea6\u3002\u4f8b\u5982&#xff0c;\u635f\u5931\u5bf9\u6743\u91cd <img decoding=\"async\" alt=\"$W$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674891c6.png\" \/>\u7684\u68af\u5ea6\u4e3a&#xff1a; <img decoding=\"async\" alt=\"$ \\\\frac{\\\\partial L}{\\\\partial W} &#061; (p - y) x^T $\" class=\"mathcode\" src=\"2025-08-15ui53l20vlgi.png\" \/>\u5176\u4e2d<img decoding=\"async\" alt=\"$y$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e8674defae.png\" \/>\u662f\u771f\u5b9e\u6807\u7b7e\u3002<\/li>\n<li>\u66f4\u65b0\u53c2\u6570&#xff1a;\u7528\u68af\u5ea6\u4e0b\u964d\u66f4\u65b0\u53c2\u6570&#xff0c;\u4f8b\u5982 <img decoding=\"async\" alt=\"$W \\\\leftarrow W - \\\\alpha \\\\frac{\\\\partial L}{\\\\partial W}$\" class=\"mathcode\" src=\"2025-08-15n3uudstphix.png\" \/>&#xff0c;\u5176\u4e2d <img decoding=\"async\" alt=\"$\\\\alpha$\" class=\"mathcode\" src=\"2025-08-15optddhchiqk.png\" \/> \u662f\u5b66\u4e60\u7387\u3002<\/li>\n<li>\u8fed\u4ee3&#xff1a;\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u76f4\u5230\u635f\u5931\u6536\u655b\u6216\u8fbe\u5230\u9884\u8bbe\u7684\u8fed\u4ee3\u6b21\u6570\u3002<\/li>\n<p>\u8bad\u7ec3\u540e&#xff0c;\u6a21\u578b\u80fd\u9884\u6d4b\u65b0\u6837\u672c\u7684\u7c7b\u522b&#xff1a;\u9009\u62e9\u6982\u7387\u6700\u9ad8\u7684<img decoding=\"async\" alt=\"$p_i$\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e867448480.png\" \/>\u5bf9\u5e94\u7684\u7c7b\u522b\u3002<\/p>\n<h2>4.\u00a0\u5e94\u7528\u573a\u666f<\/h2>\n<p>Softmax\u56de\u5f52\u7b80\u5355\u9ad8\u6548&#xff0c;\u5e38\u7528\u4e8e&#xff1a;<\/p>\n<ul>\n<li>\u56fe\u50cf\u5206\u7c7b&#xff08;\u5982MNIST\u624b\u5199\u6570\u5b57\u8bc6\u522b&#xff09;\u3002<\/li>\n<li>\u6587\u672c\u5206\u7c7b&#xff08;\u5982\u60c5\u611f\u5206\u6790&#xff09;\u3002<\/li>\n<li>\u4f5c\u4e3a\u795e\u7ecf\u7f51\u7edc\u8f93\u51fa\u5c42&#xff08;\u4f8b\u5982&#xff0c;\u5728\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u540e\u63a5softmax\u5c42&#xff09;\u3002<\/li>\n<\/ul>\n<h2>5.\u00a0\u4ee3\u7801\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u5b9e\u73b0&#xff0c;\u4f7f\u7528NumPy\u5e93\u8fdb\u884c\u6570\u503c\u8ba1\u7b97\u3002\u4ee3\u7801\u5305\u62ec\u6a21\u578b\u5b9a\u4e49\u3001\u8bad\u7ec3\u548c\u9884\u6d4b\u529f\u80fd\u3002<\/p>\n<p>import numpy as np<\/p>\n<p>class SoftmaxRegression:<br \/>\n    def __init__(self, num_classes, input_dim, learning_rate&#061;0.01, max_iter&#061;1000):<br \/>\n        self.num_classes &#061; num_classes<br \/>\n        self.input_dim &#061; input_dim<br \/>\n        self.learning_rate &#061; learning_rate<br \/>\n        self.max_iter &#061; max_iter<br \/>\n        self.W &#061; np.random.randn(num_classes, input_dim) * 0.01  # \u521d\u59cb\u5316\u6743\u91cd<br \/>\n        self.b &#061; np.zeros((num_classes, 1))  # \u521d\u59cb\u5316\u504f\u7f6e<\/p>\n<p>    def softmax(self, z):<br \/>\n        # \u8ba1\u7b97softmax\u6982\u7387<br \/>\n        exp_z &#061; np.exp(z &#8211; np.max(z, axis&#061;0, keepdims&#061;True))  # \u907f\u514d\u6570\u503c\u6ea2\u51fa<br \/>\n        return exp_z \/ np.sum(exp_z, axis&#061;0, keepdims&#061;True)<\/p>\n<p>    def fit(self, X, y):<br \/>\n        # \u8bad\u7ec3\u6a21\u578b&#xff1a;X\u662f\u7279\u5f81\u77e9\u9635(N x d), y\u662f\u6807\u7b7e\u5411\u91cf(N,)&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u662f\u7c7b\u522b\u7d22\u5f15<br \/>\n        N &#061; X.shape[0]<br \/>\n        y_one_hot &#061; np.eye(self.num_classes)[y]  # \u8f6c\u6362\u4e3aone-hot\u7f16\u7801 (N x K)<\/p>\n<p>        for _ in range(self.max_iter):<br \/>\n            # \u524d\u5411\u4f20\u64ad<br \/>\n            z &#061; self.W &#064; X.T &#043; self.b  # \u8ba1\u7b97logits (K x N)<br \/>\n            p &#061; self.softmax(z)  # \u6982\u7387\u77e9\u9635 (K x N)<\/p>\n<p>            # \u8ba1\u7b97\u635f\u5931&#xff08;\u4ea4\u53c9\u71b5&#xff09;<br \/>\n            loss &#061; -np.mean(np.log(p[y_one_hot.T &#061;&#061; 1] &#043; 1e-8))  # \u52a0\u5c0f\u503c\u9632log(0)<\/p>\n<p>            # \u53cd\u5411\u4f20\u64ad&#xff1a;\u8ba1\u7b97\u68af\u5ea6<br \/>\n            grad_z &#061; p &#8211; y_one_hot.T  # \u68af\u5ea6\u5bf9z (K x N)<br \/>\n            grad_W &#061; grad_z &#064; X \/ N  # \u5e73\u5747\u68af\u5ea6 (K x d)<br \/>\n            grad_b &#061; np.mean(grad_z, axis&#061;1, keepdims&#061;True)  # \u5e73\u5747\u68af\u5ea6 (K x 1)<\/p>\n<p>            # \u66f4\u65b0\u53c2\u6570<br \/>\n            self.W -&#061; self.learning_rate * grad_W<br \/>\n            self.b -&#061; self.learning_rate * grad_b<\/p>\n<p>        return loss<\/p>\n<p>    def predict(self, X):<br \/>\n        # \u9884\u6d4b\u7c7b\u522b&#xff1a;\u8fd4\u56de\u6982\u7387\u6700\u9ad8\u7684\u7d22\u5f15<br \/>\n        z &#061; self.W &#064; X.T &#043; self.b<br \/>\n        p &#061; self.softmax(z)<br \/>\n        return np.argmax(p, axis&#061;0)<\/p>\n<p># \u793a\u4f8b\u4f7f\u7528<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    # \u5047\u8bbe\u6709\u7b80\u5355\u6570\u636e\u96c6&#xff1a;2\u4e2a\u7279\u5f81&#xff0c;3\u4e2a\u7c7b\u522b<br \/>\n    X_train &#061; np.array([[1.0, 2.0], [2.0, 3.0], [3.0, 1.0]])  # \u8bad\u7ec3\u7279\u5f81<br \/>\n    y_train &#061; np.array([0, 1, 2])  # \u8bad\u7ec3\u6807\u7b7e&#xff08;\u7c7b\u522b\u7d22\u5f15&#xff09;<\/p>\n<p>    # \u521b\u5efa\u5e76\u8bad\u7ec3\u6a21\u578b<br \/>\n    model &#061; SoftmaxRegression(num_classes&#061;3, input_dim&#061;2, learning_rate&#061;0.1, max_iter&#061;1000)<br \/>\n    loss &#061; model.fit(X_train, y_train)<br \/>\n    print(f&#034;\u8bad\u7ec3\u635f\u5931: {loss:.4f}&#034;)<\/p>\n<p>    # \u9884\u6d4b\u65b0\u6837\u672c<br \/>\n    X_test &#061; np.array([[1.5, 1.5]])<br \/>\n    pred &#061; model.predict(X_test)<br \/>\n    print(f&#034;\u9884\u6d4b\u7c7b\u522b: {pred[0]}&#034;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb126\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf3\u6b21\u3002Softmax\u56de\u5f52\u662f\u4e00\u79cd\u591a\u7c7b\u5206\u7c7b\u7b97\u6cd5\uff0c\u901a\u8fc7softmax\u51fd\u6570\u5c06\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8f6c\u6362\u4e3a\u6982\u7387\u5206\u5e03\u3002\u8be5\u7b97\u6cd5\u4f7f\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u4f18\u5316\u6743\u91cd\u548c\u504f\u7f6e\u53c2\u6570\uff0c\u9002\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u6587\u672c\u5206\u7c7b\u7b49\u573a\u666f\u3002\u5176\u8bad\u7ec3\u8fc7\u7a0b\u5305\u62ec\u524d\u5411\u4f20\u64ad\u8ba1\u7b97\u6982\u7387\u3001\u53cd\u5411\u4f20\u64ad\u6c42\u68af\u5ea6\u5e76\u66f4\u65b0\u53c2\u6570\u3002\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u7528NumPy\u5b9e\u73b0Softmax\u56de\u5f52\u6a21\u578b\uff0c\u5305\u62ec\u8bad\u7ec3\u548c\u9884\u6d4b\u529f\u80fd\u3002Softmax\u56de\u5f52\u7b80\u5355\u9ad8\u6548\uff0c\u5e38\u4f5c\u4e3a\u795e\u7ecf\u7f51\u7edc\u8f93\u51fa\u5c42\u5904\u7406\u591a\u5206\u7c7b\u95ee\u9898\u3002<\/p>\n","protected":false},"author":2,"featured_media":57197,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[587,152,5576,86],"topic":[],"class_list":{"0":"post-57217","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-587","9":"tag-pytorch","11":"tag-86"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/57217.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb126\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf3\u6b21\u3002Softmax\u56de\u5f52\u662f\u4e00\u79cd\u591a\u7c7b\u5206\u7c7b\u7b97\u6cd5\uff0c\u901a\u8fc7softmax\u51fd\u6570\u5c06\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8f6c\u6362\u4e3a\u6982\u7387\u5206\u5e03\u3002\u8be5\u7b97\u6cd5\u4f7f\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u4f18\u5316\u6743\u91cd\u548c\u504f\u7f6e\u53c2\u6570\uff0c\u9002\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u6587\u672c\u5206\u7c7b\u7b49\u573a\u666f\u3002\u5176\u8bad\u7ec3\u8fc7\u7a0b\u5305\u62ec\u524d\u5411\u4f20\u64ad\u8ba1\u7b97\u6982\u7387\u3001\u53cd\u5411\u4f20\u64ad\u6c42\u68af\u5ea6\u5e76\u66f4\u65b0\u53c2\u6570\u3002\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u7528NumPy\u5b9e\u73b0Softmax\u56de\u5f52\u6a21\u578b\uff0c\u5305\u62ec\u8bad\u7ec3\u548c\u9884\u6d4b\u529f\u80fd\u3002Softmax\u56de\u5f52\u7b80\u5355\u9ad8\u6548\uff0c\u5e38\u4f5c\u4e3a\u795e\u7ecf\u7f51\u7edc\u8f93\u51fa\u5c42\u5904\u7406\u591a\u5206\u7c7b\u95ee\u9898\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57217.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T00:59:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86742cbc6.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57217.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57217.html\",\"name\":\"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T00:59:34+00:00\",\"dateModified\":\"2025-08-15T00:59:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57217.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57217.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57217.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/57217.html","og_locale":"zh_CN","og_type":"article","og_title":"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb126\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf3\u6b21\u3002Softmax\u56de\u5f52\u662f\u4e00\u79cd\u591a\u7c7b\u5206\u7c7b\u7b97\u6cd5\uff0c\u901a\u8fc7softmax\u51fd\u6570\u5c06\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8f6c\u6362\u4e3a\u6982\u7387\u5206\u5e03\u3002\u8be5\u7b97\u6cd5\u4f7f\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u4f18\u5316\u6743\u91cd\u548c\u504f\u7f6e\u53c2\u6570\uff0c\u9002\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u6587\u672c\u5206\u7c7b\u7b49\u573a\u666f\u3002\u5176\u8bad\u7ec3\u8fc7\u7a0b\u5305\u62ec\u524d\u5411\u4f20\u64ad\u8ba1\u7b97\u6982\u7387\u3001\u53cd\u5411\u4f20\u64ad\u6c42\u68af\u5ea6\u5e76\u66f4\u65b0\u53c2\u6570\u3002\u793a\u4f8b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u7528NumPy\u5b9e\u73b0Softmax\u56de\u5f52\u6a21\u578b\uff0c\u5305\u62ec\u8bad\u7ec3\u548c\u9884\u6d4b\u529f\u80fd\u3002Softmax\u56de\u5f52\u7b80\u5355\u9ad8\u6548\uff0c\u5e38\u4f5c\u4e3a\u795e\u7ecf\u7f51\u7edc\u8f93\u51fa\u5c42\u5904\u7406\u591a\u5206\u7c7b\u95ee\u9898\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/57217.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T00:59:34+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815005932-689e86742cbc6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57217.html","url":"https:\/\/www.wsisp.com\/helps\/57217.html","name":"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T00:59:34+00:00","dateModified":"2025-08-15T00:59:34+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57217.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57217.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57217.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\uff08pytorch\u7248\uff09\uff1a\u7b2c\u4e09\u7ae0\u8282\u2014\u7ebf\u6027\u795e\u7ecf\u7f51\u7edc\uff084\uff09softmax\u56de\u5f52"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=57217"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57217\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/57197"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57217"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}