{"id":2101,"date":"2023-04-01T22:15:45","date_gmt":"2023-04-01T14:15:45","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2101"},"modified":"2023-04-06T13:56:27","modified_gmt":"2023-04-06T05:56:27","slug":"fundamentals-of-deep-learning-linear-algebra-inverse-matrix-and-pseudo-inverse-matrix","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/fundamentals-of-deep-learning-linear-algebra-inverse-matrix-and-pseudo-inverse-matrix\/","title":{"rendered":"\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\uff1a\u7ebf\u6027\u4ee3\u6570(3)_\u9006\u77e9\u9635\u4e0e\u4f2a\u9006\u77e9\u9635"},"content":{"rendered":"<h2>\u77e9\u9635\u7684\u9006<\/h2>\n<h3>\u5b9a\u4e49<\/h3>\n<p>\u77e9\u9635$A$\u7684<strong>\u9006\u77e9\u9635<\/strong>\u8bb0\u4f5c$A^{-1}$\uff0c\u5176\u5b9a\u4e49\u7684\u77e9\u9635\u6ee1\u8db3\u5982\u4e0b\u6761\u4ef6<\/p>\n<p><!-- more --><\/p>\n<p>$$AA^{-1} = A^{-1}A = E$$<\/p>\n<p>\u5176\u4e2d$E$\u662f\u5355\u4f4d\u77e9\u9635\u3002<\/p>\n<h3>Python\u5b9e\u73b0<\/h3>\n<h4>Numpy<\/h4>\n<pre><code class=\"language-python\">import numpy as np\n\nA = np.array([[1, 2],\n              [3, 4]])\n# \u6c42\u9006\u77e9\u9635\nA_inv = np.linalg.inv(A)\nprint(A_inv)\nprint(np.dot(A, A_inv))<\/code><\/pre>\n<h4>Scipy<\/h4>\n<pre><code class=\"language-python\">import numpy as np\nimport scipy as sp\nfrom scipy import linalg\n\nA = np.array([[1, 2],\n              [3, 4]])\n# \u6c42\u9006\u77e9\u9635\nA_inv = linalg.inv(A)\nprint(A_inv)\nprint(np.dot(A, A_inv))<\/code><\/pre>\n<h2>Moore-Penrose\u4f2a\u9006<\/h2>\n<h3>\u5b9a\u4e49<\/h3>\n<p>\u77e9\u9635$A$\u7684\u4f2a\u9006\u5b9a\u4e49\u4e3a\uff1a<\/p>\n<p>$$<br \/>\nA^+ = \\lim \\limits_{\\alpha \\to 0} (A^TA + \\alpha E)^{-1}A^T<br \/>\n$$<\/p>\n<p>\u5728\u5b9e\u9645\u7684\u8ba1\u7b97\u4e2d\u4e0d\u4f7f\u7528\u8fd9\u4e2a\u5b9a\u4e49\uff0c\u800c\u662f\u4f7f\u7528\u4e0b\u9762\u7684\u516c\u5f0f\uff1a<\/p>\n<p>$$<br \/>\nA^+ = VD^+U^T<br \/>\n$$<\/p>\n<p>\u5176\u4e2d\uff0c$U$\uff0c$D$\u548c$V$\u662f\u77e9\u9635\u5947\u5f02\u503c\u5206\u89e3\u540e\u5f97\u5230\u7684\u77e9\u9635\u3002\u5bf9\u89d2\u77e9\u9635$D$\u7684\u4f2a\u9006$D^+$\u662f\u5176\u975e\u96f6\u5143\u7d20\u53d6\u5012\u6570\u4e4b\u540e\u518d\u8f6c\u7f6e\u5f97\u5230\u7684\u3002<\/p>\n<h3>\u6027\u8d28<\/h3>\n<p>\uff081\uff09\u5f53\u77e9\u9635$A$\u7684\u5217\u6570\u591a\u4e8e\u884c\u6570\u65f6\uff0c\u4f7f\u7528\u4f2a\u9006\u6c42\u89e3\u7ebf\u6027\u65b9\u7a0b\u662f\u4f17\u591a\u53ef\u80fd\u89e3\u6cd5\u4e2d\u7684\u4e00\u79cd\u3002\u7279\u522b\u5730\uff0c$x = A^+y$\u662f\u65b9\u7a0b\u6240\u6709\u53ef\u884c\u89e3\u4e2d\u6b27\u51e0\u91cc\u5f97\u8303\u6570$||x||_2$\u6700\u5c0f\u7684\u4e00\u4e2a\u3002<br \/>\n\uff082\uff09\u5f53\u77e9\u9635$A$\u7684\u884c\u6570\u591a\u4e8e\u5217\u6570\u65f6\uff0c\u53ef\u80fd\u6ca1\u6709\u89e3\u3002\u6b64\u65f6\u4f7f\u7528\u4f2a\u9006\u5f97\u5230\u7684$x$\uff0c\u4f7f\u5f97$Ax$\u548c$y$\u7684\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb$||Ax &#8211; y||_2$\u6700\u5c0f\u3002<\/p>\n<h3>Python\u5b9e\u73b0<\/h3>\n<h4>Numpy<\/h4>\n<pre><code class=\"language-python\">import numpy as np\n\nA = np.array([[1, 2],\n              [3, 4],\n              [5, 6]])\nA_pinv = np.linalg.pinv(A)\nprint(A_pinv)\nprint(np.dot(A_pinv, A))<\/code><\/pre>\n<h4>Scipy<\/h4>\n<pre><code class=\"language-python\">import numpy as np\nimport scipy as sp\nfrom scipy import linalg\n\nA = np.array([[1, 2],\n              [3, 4],\n              [5, 6]])\nA_pinv = sp.linalg.pinv(A)\nprint(A_pinv)\nprint(np.dot(A_pinv, A))<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u77e9\u9635\u7684\u9006 \u5b9a\u4e49 \u77e9\u9635$A$\u7684\u9006\u77e9\u9635\u8bb0\u4f5c$A^{-1}$\uff0c\u5176\u5b9a\u4e49\u7684\u77e9\u9635\u6ee1\u8db3\u5982\u4e0b\u6761\u4ef6 $$AA^{-1} = A^ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[527],"tags":[531],"class_list":["post-2101","post","type-post","status-publish","format-standard","hentry","category-ai","tag-531"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2101"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2101\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}