{"id":930887,"date":"2024-12-26T17:26:01","date_gmt":"2024-12-26T09:26:01","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/930887.html"},"modified":"2024-12-26T17:26:03","modified_gmt":"2024-12-26T09:26:03","slug":"python%e5%a6%82%e4%bd%95%e7%82%b9%e4%b9%98","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/930887.html","title":{"rendered":"python\u5982\u4f55\u70b9\u4e58"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065433\/1728253f-b4aa-4889-a912-011cfaa72cad.webp\" alt=\"python\u5982\u4f55\u70b9\u4e58\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u8fdb\u884c\u70b9\u4e58\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u7684<code>dot<\/code>\u51fd\u6570\u3001<code>@<\/code>\u8fd0\u7b97\u7b26\u3001\u4ee5\u53ca\u5217\u8868\u63a8\u5bfc\u5f0f<\/strong>\u3002\u5728Python\u4e2d\uff0c\u70b9\u4e58\u662f\u6307\u4e24\u4e2a\u5411\u91cf\u6216\u6570\u7ec4\u5bf9\u5e94\u5143\u7d20\u76f8\u4e58\u5e76\u7d2f\u52a0\u5f97\u5230\u4e00\u4e2a\u6807\u91cf\u3002\u8fd9\u91cc\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u51e0\u79cd\u65b9\u6cd5\u8fdb\u884c\u70b9\u4e58\u3002<\/p>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u70b9\u4e58\u64cd\u4f5c\u65f6\uff0cNumPy\u5e93\u662f\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u7ec4\u64cd\u4f5c\u548c\u7ebf\u6027\u4ee3\u6570\u529f\u80fd\u3002<code>dot<\/code>\u51fd\u6570\u662fNumPy\u4e2d\u7528\u4e8e\u6267\u884c\u70b9\u4e58\u7684\u4e3b\u8981\u51fd\u6570\u4e4b\u4e00\u3002\u9664\u4e86NumPy\uff0cPython\u7684\u57fa\u672c\u5217\u8868\u64cd\u4f5c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u70b9\u4e58\uff0c\u4f46\u6548\u7387\u76f8\u5bf9\u8f83\u4f4e\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u4f7f\u7528NumPy\u6765\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001NUMPY\u5e93\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>NumPy\u662fPython\u4e2d\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u64cd\u4f5c\u7684\u57fa\u7840\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u7ebf\u6027\u4ee3\u6570\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528<code>dot<\/code>\u51fd\u6570<\/h4>\n<\/p>\n<p><p>NumPy\u4e2d\u7684<code>dot<\/code>\u51fd\u6570\u662f\u6267\u884c\u70b9\u4e58\u7684\u6807\u51c6\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u5b9a\u4e49\u4e24\u4e2a\u5411\u91cf<\/strong><\/h2>\n<p>vector_a = np.array([1, 2, 3])<\/p>\n<p>vector_b = np.array([4, 5, 6])<\/p>\n<h2><strong>\u4f7f\u7528dot\u51fd\u6570\u8fdb\u884c\u70b9\u4e58<\/strong><\/h2>\n<p>result = np.dot(vector_a, vector_b)<\/p>\n<p>print(f&quot;\u70b9\u4e58\u7ed3\u679c\u662f: {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>np.dot<\/code>\u51fd\u6570\u8ba1\u7b97\u4e86\u4e24\u4e2a\u5411\u91cf\u7684\u70b9\u4e58\u3002\u70b9\u4e58\u7684\u7ed3\u679c\u662f32\uff0c\u8fd9\u662f\u901a\u8fc7\u5c06\u4e24\u4e2a\u5411\u91cf\u7684\u5bf9\u5e94\u5143\u7d20\u76f8\u4e58\u5e76\u7d2f\u52a0\u5f97\u5230\u7684\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528<code>@<\/code>\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>\u5728Python 3.5\u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c<code>@<\/code>\u8fd0\u7b97\u7b26\u4e5f\u53ef\u4ee5\u7528\u4e8e\u70b9\u4e58\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528@\u8fd0\u7b97\u7b26\u8fdb\u884c\u70b9\u4e58<\/p>\n<p>result = vector_a @ vector_b<\/p>\n<p>print(f&quot;\u4f7f\u7528@\u8fd0\u7b97\u7b26\u7684\u70b9\u4e58\u7ed3\u679c\u662f: {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u65b9\u6cd5\u4e0e<code>np.dot<\/code>\u529f\u80fd\u76f8\u540c\uff0c\u4f46\u8bed\u6cd5\u66f4\u7b80\u6d01\u76f4\u89c2\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u5b9e\u73b0\u70b9\u4e58<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u8f83\u5c0f\u7684\u6570\u636e\u96c6\uff0c\u4f7f\u7528\u7eafPython\u7684\u5217\u8868\u63a8\u5bfc\u5f0f\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u70b9\u4e58\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u8fdb\u884c\u70b9\u4e58<\/p>\n<p>result = sum([a * b for a, b in zip(vector_a, vector_b)])<\/p>\n<p>print(f&quot;\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u7684\u70b9\u4e58\u7ed3\u679c\u662f: {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>zip<\/code>\u51fd\u6570\u5c06\u4e24\u4e2a\u5411\u91cf\u7684\u5bf9\u5e94\u5143\u7d20\u914d\u5bf9\uff0c\u7136\u540e\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\u8fdb\u884c\u4e58\u79ef\u8fd0\u7b97\uff0c\u6700\u540e\u4f7f\u7528<code>sum<\/code>\u51fd\u6570\u6c42\u548c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5bf9\u591a\u7ef4\u6570\u7ec4\u7684\u70b9\u4e58<\/h3>\n<\/p>\n<p><p>NumPy\u4e0d\u4ec5\u53ef\u4ee5\u5904\u7406\u4e00\u7ef4\u5411\u91cf\u7684\u70b9\u4e58\uff0c\u4e5f\u53ef\u4ee5\u5904\u7406\u591a\u7ef4\u6570\u7ec4\uff08\u5982\u77e9\u9635\uff09\u7684\u70b9\u4e58\u3002<\/p>\n<\/p>\n<p><h4>1. \u77e9\u9635\u4e0e\u5411\u91cf\u7684\u70b9\u4e58<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u77e9\u9635\u548c\u4e00\u4e2a\u5411\u91cf<\/p>\n<p>matrix = np.array([[1, 2], [3, 4], [5, 6]])<\/p>\n<p>vector = np.array([1, 1])<\/p>\n<h2><strong>\u8fdb\u884c\u77e9\u9635\u4e0e\u5411\u91cf\u7684\u70b9\u4e58<\/strong><\/h2>\n<p>result = np.dot(matrix, vector)<\/p>\n<p>print(f&quot;\u77e9\u9635\u4e0e\u5411\u91cf\u7684\u70b9\u4e58\u7ed3\u679c\u662f: {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>np.dot<\/code>\u51fd\u6570\u8ba1\u7b97\u4e86\u77e9\u9635\u548c\u5411\u91cf\u7684\u70b9\u4e58\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u5411\u91cf\u3002<\/p>\n<\/p>\n<p><h4>2. \u77e9\u9635\u4e0e\u77e9\u9635\u7684\u70b9\u4e58<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u77e9\u9635<\/p>\n<p>matrix_a = np.array([[1, 2, 3], [4, 5, 6]])<\/p>\n<p>matrix_b = np.array([[7, 8], [9, 10], [11, 12]])<\/p>\n<h2><strong>\u8fdb\u884c\u77e9\u9635\u4e0e\u77e9\u9635\u7684\u70b9\u4e58<\/strong><\/h2>\n<p>result = np.dot(matrix_a, matrix_b)<\/p>\n<p>print(f&quot;\u77e9\u9635\u4e0e\u77e9\u9635\u7684\u70b9\u4e58\u7ed3\u679c\u662f:\\n{result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>np.dot<\/code>\u51fd\u6570\u8ba1\u7b97\u4e86\u4e24\u4e2a\u77e9\u9635\u7684\u70b9\u4e58\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a\u65b0\u7684\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6027\u80fd\u4e0e\u4f18\u5316<\/h3>\n<\/p>\n<p><p>\u5728\u5927\u89c4\u6a21\u6570\u636e\u8ba1\u7b97\u4e2d\uff0cNumPy\u63d0\u4f9b\u7684\u9ad8\u6548\u7b97\u6cd5\u548cC\u8bed\u8a00\u5b9e\u73b0\u4f7f\u5f97\u70b9\u4e58\u64cd\u4f5c\u975e\u5e38\u5feb\u901f\u3002\u76f8\u6bd4\u7eafPython\u5b9e\u73b0\uff0cNumPy\u7684\u64cd\u4f5c\u5f80\u5f80\u80fd\u63d0\u4f9b\u6570\u91cf\u7ea7\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528NumPy\u7684\u4f18\u52bf<\/h4>\n<\/p>\n<p><p>NumPy\u7684\u5e95\u5c42\u5b9e\u73b0\u4f7f\u7528\u4e86\u9ad8\u6548\u7684C\u548cFortran\u4ee3\u7801\uff0c\u8fd9\u4f7f\u5f97\u5b83\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u65f6\u975e\u5e38\u9ad8\u6548\u3002\u6b64\u5916\uff0cNumPy\u8fd8\u652f\u6301\u591a\u7ebf\u7a0b\u548c\u5e76\u884c\u8ba1\u7b97\uff0c\u8fd9\u8fdb\u4e00\u6b65\u63d0\u9ad8\u4e86\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>2. \u5904\u7406\u5927\u578b\u6570\u636e\u96c6<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u65f6\uff0c\u4f7f\u7528NumPy\u7684\u6570\u7ec4\u548c\u77e9\u9635\u7ed3\u6784\u53ef\u4ee5\u8282\u7701\u5185\u5b58\uff0c\u5e76\u52a0\u5feb\u8ba1\u7b97\u901f\u5ea6\u3002NumPy\u7684\u5e7f\u64ad\u673a\u5236\u4e5f\u5141\u8bb8\u5728\u4e0d\u590d\u5236\u6570\u636e\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u8de8\u7ef4\u5ea6\u7684\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u70b9\u4e58\u5728\u5404\u79cd\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u4e2d\u90fd\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u5728<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u4e2d\uff0c\u70b9\u4e58\u7528\u4e8e\u8ba1\u7b97\u795e\u7ecf\u7f51\u7edc\u7684\u52a0\u6743\u548c\u8f93\u5165\u3002\u5728\u7269\u7406\u5b66\u4e2d\uff0c\u70b9\u4e58\u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u573a\u7684\u901a\u91cf\u3002<\/p>\n<\/p>\n<p><h4>1. \u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5e94\u7528<\/h4>\n<\/p>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u70b9\u4e58\u7528\u4e8e\u8ba1\u7b97\u6a21\u578b\u7684\u9884\u6d4b\u503c\u3002\u4f8b\u5982\uff0c\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u7684\u9884\u6d4b\u5c31\u662f\u901a\u8fc7\u8f93\u5165\u7279\u5f81\u5411\u91cf\u4e0e\u6a21\u578b\u6743\u91cd\u5411\u91cf\u7684\u70b9\u4e58\u5f97\u5230\u7684\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\uff1a\u7ebf\u6027\u56de\u5f52\u9884\u6d4b<\/p>\n<p>features = np.array([1.5, 2.5])<\/p>\n<p>weights = np.array([0.4, 0.6])<\/p>\n<h2><strong>\u8ba1\u7b97\u9884\u6d4b\u503c<\/strong><\/h2>\n<p>prediction = np.dot(features, weights)<\/p>\n<p>print(f&quot;\u7ebf\u6027\u56de\u5f52\u9884\u6d4b\u503c\u662f: {prediction}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u7269\u7406\u5b66\u4e2d\u7684\u5e94\u7528<\/h4>\n<\/p>\n<p><p>\u5728\u7269\u7406\u5b66\u4e2d\uff0c\u70b9\u4e58\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u6295\u5f71\u3002\u4f8b\u5982\uff0c\u8ba1\u7b97\u529b\u4e0e\u4f4d\u79fb\u7684\u70b9\u4e58\u53ef\u4ee5\u5f97\u5230\u505a\u529f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\uff1a\u8ba1\u7b97\u505a\u529f<\/p>\n<p>force = np.array([10, 0])<\/p>\n<p>displacement = np.array([5, 0])<\/p>\n<h2><strong>\u8ba1\u7b97\u505a\u529f<\/strong><\/h2>\n<p>work_done = np.dot(force, displacement)<\/p>\n<p>print(f&quot;\u505a\u529f\u662f: {work_done} \u7126\u8033&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u8fdb\u884c\u70b9\u4e58\u7684\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528NumPy\u5e93\u7684<code>dot<\/code>\u51fd\u6570\u548c<code>@<\/code>\u8fd0\u7b97\u7b26\uff0c\u4ee5\u53ca\u5217\u8868\u63a8\u5bfc\u5f0f\u3002\u5bf9\u4e8e\u5927\u578b\u6570\u636e\u96c6\uff0c\u5efa\u8bae\u4f7f\u7528NumPy\u8fdb\u884c\u8ba1\u7b97\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u5e95\u5c42\u5b9e\u73b0\u548c\u4e30\u5bcc\u7684\u7ebf\u6027\u4ee3\u6570\u529f\u80fd\u3002\u5728\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u65f6\uff0cNumPy\u540c\u6837\u63d0\u4f9b\u4e86\u7075\u6d3b\u548c\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u56e0\u6b64\uff0c\u5728\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u4e2d\uff0cNumPy\u662f\u4e00\u4e2a\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5b9e\u73b0\u77e9\u9635\u7684\u70b9\u4e58\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u6765\u8f7b\u677e\u5b9e\u73b0\u77e9\u9635\u7684\u70b9\u4e58\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5NumPy\u5e93\uff0c\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>pip install numpy<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>numpy.dot()<\/code>\u51fd\u6570\u6216<code>@<\/code>\u8fd0\u7b97\u7b26\u6765\u8ba1\u7b97\u4e24\u4e2a\u77e9\u9635\u7684\u70b9\u4e58\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">import numpy as np\n\nA = np.array([[1, 2], [3, 4]])\nB = np.array([[5, 6], [7, 8]])\nresult = np.dot(A, B)  # \u6216\u8005\u4f7f\u7528 result = A @ B\nprint(result)\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u8f93\u51fa\u70b9\u4e58\u7684\u7ed3\u679c\u3002<\/p>\n<p><strong>Python\u7684\u70b9\u4e58\u4e0e\u9010\u5143\u7d20\u76f8\u4e58\u6709\u4f55\u4e0d\u540c\uff1f<\/strong><br \/>\u70b9\u4e58\uff08\u4e5f\u79f0\u4e3a\u5185\u79ef\uff09\u548c\u9010\u5143\u7d20\u76f8\u4e58\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u64cd\u4f5c\u3002\u70b9\u4e58\u6d89\u53ca\u4e24\u4e2a\u77e9\u9635\u6216\u5411\u91cf\u7684\u4e58\u6cd5\u8fd0\u7b97\uff0c\u7ed3\u679c\u901a\u5e38\u662f\u4e00\u4e2a\u6807\u91cf\u6216\u53e6\u4e00\u4e2a\u77e9\u9635\u3002\u800c\u9010\u5143\u7d20\u76f8\u4e58\u5219\u662f\u5bf9\u5e94\u5143\u7d20\u4e4b\u95f4\u7684\u4e58\u6cd5\uff0c\u7ed3\u679c\u4e0e\u539f\u77e9\u9635\u5f62\u72b6\u76f8\u540c\u3002\u5728NumPy\u4e2d\uff0c\u9010\u5143\u7d20\u76f8\u4e58\u53ef\u4ee5\u901a\u8fc7<code>*<\/code>\u8fd0\u7b97\u7b26\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">C = A * B  # \u9010\u5143\u7d20\u76f8\u4e58\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u8fd4\u56de\u6bcf\u4e2a\u5143\u7d20\u7684\u4e58\u79ef\uff0c\u8f93\u51fa\u7684\u77e9\u9635\u4e0e\u539f\u59cb\u77e9\u9635\u5f62\u72b6\u76f8\u540c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u8fdb\u884c\u70b9\u4e58\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u70b9\u4e58\u65f6\uff0c\u786e\u4fdd\u4e24\u4e2a\u6570\u7ec4\u7684\u7ef4\u5ea6\u662f\u517c\u5bb9\u7684\u3002\u5bf9\u4e8e\u4e8c\u7ef4\u6570\u7ec4\uff0c\u524d\u4e00\u4e2a\u6570\u7ec4\u7684\u5217\u6570\u5fc5\u987b\u7b49\u4e8e\u540e\u4e00\u4e2a\u6570\u7ec4\u7684\u884c\u6570\u3002\u5982\u679c\u5f62\u72b6\u4e0d\u5339\u914d\uff0cPython\u5c06\u629b\u51fa\u9519\u8bef\u3002\u53ef\u4ee5\u4f7f\u7528<code>reshape()<\/code>\u51fd\u6570\u8c03\u6574\u6570\u7ec4\u7684\u5f62\u72b6\uff0c\u6216\u901a\u8fc7\u8f6c\u7f6e\uff08<code>T<\/code>\uff09\u4f7f\u5176\u517c\u5bb9\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">A = np.array([[1, 2, 3], [4, 5, 6]])\nB = np.array([[1, 2], [3, 4], [5, 6]])\nresult = np.dot(A, B.T)  # \u5c06B\u8f6c\u7f6e\u4ee5\u5339\u914d\u5f62\u72b6\nprint(result)\n<\/code><\/pre>\n<p>\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u8fdb\u884c\u70b9\u4e58\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u8fdb\u884c\u70b9\u4e58\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u7684dot\u51fd\u6570\u3001@\u8fd0\u7b97\u7b26\u3001\u4ee5\u53ca\u5217\u8868\u63a8\u5bfc\u5f0f\u3002\u5728Python\u4e2d\uff0c\u70b9\u4e58\u662f\u6307\u4e24 [&hellip;]","protected":false},"author":3,"featured_media":930893,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/930887"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=930887"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/930887\/revisions"}],"predecessor-version":[{"id":930894,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/930887\/revisions\/930894"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/930893"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=930887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=930887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=930887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}