{"id":2102,"date":"2023-04-01T22:16:36","date_gmt":"2023-04-01T14:16:36","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2102"},"modified":"2023-04-06T13:56:14","modified_gmt":"2023-04-06T05:56:14","slug":"fundamentals-of-deep-learning-linear-algebra-norm","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/fundamentals-of-deep-learning-linear-algebra-norm\/","title":{"rendered":"\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\uff1a\u7ebf\u6027\u4ee3\u6570(4)_\u8303\u6570"},"content":{"rendered":"<h2>Lp\u8303\u6570<\/h2>\n<p>$$<br \/>\n\\mid\\mid x\\mid\\mid<em>p = (\\sum<\/em>{i}|x_i|^p)^{\\frac {1} {p}}<br \/>\n$$<\/p>\n<p><!-- more --><\/p>\n<p>\u5176\u4e2d$p \\in {\\Bbb {R}}, p \\geq 1$<\/p>\n<p>$L_1$\u8303\u6570\uff1a$ \\mid \\mid x\\mid\\mid<em>1 = \\sum<\/em>{i} x_i $<br \/>\n$L_2$\u8303\u6570\uff1a$ \\mid \\mid x\\mid\\mid<em>2 = \\sqrt{\\sum<\/em>{i} x<em>i^2} $<br \/>\n$L<\/em>\\infty$\u8303\u6570\uff1a$ \\mid \\mid x\\mid\\mid_\\infty = max \\mid x_i\\mid $<\/p>\n<h2>Frobenius\u8303\u6570<\/h2>\n<p>Frobenius\u8303\u6570\u662f\u7528\u6765\u8861\u91cf\u77e9\u9635\u7684\u5927\u5c0f\uff0c\u5176\u5b9a\u4e49\uff1a<\/p>\n<p>$$<br \/>\n||x||<em>F = \\sqrt{\\sum<\/em>{i,j}A_{i,j}^2}<br \/>\n$$<\/p>\n<p>\u5c31\u662f\u77e9\u9635\u7684\u6bcf\u4e2a\u5143\u7d20\u53d6\u5e73\u65b9\u518d\u6c42\u548c\uff0c\u6700\u7ec8\u5f00\u5e73\u65b9\u3002\u7c7b\u4f3c\u4e8e$L_2$\u8303\u6570\u3002<\/p>\n<h2>Python\u5b9e\u73b0<\/h2>\n<pre><code>norm(x, ord=None, axis=None, keepdims=False)<\/code><\/pre>\n<p>x\u8868\u793a\u8981\u5ea6\u91cf\u7684\u5411\u91cf\uff0cord\u8868\u793a\u8303\u6570\u7684\u79cd\u7c7b<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<th style=\"text-align: left;\">\u8ba1\u7b97\u65b9\u6cd5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">\u9ed8\u8ba4<\/td>\n<td style=\"text-align: left;\">\u4e8c\u8303\u6570\uff1a$l_2$<\/td>\n<td style=\"text-align: left;\">$\\sqrt{x_1^2 + x_2^2 + \\cdots + x_n^2}$<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ord=2<\/td>\n<td style=\"text-align: left;\">\u4e8c\u8303\u6570\uff1a$l_2$<\/td>\n<td style=\"text-align: left;\">\u540c\u4e0a<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ord=1<\/td>\n<td style=\"text-align: left;\">\u4e00\u8303\u6570\uff1a$l_1$<\/td>\n<td style=\"text-align: left;\">$\\mid x_1\\mid + \\mid x_2\\mid + \\cdots + \\mid x_n\\mid$<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ord=np.inf<\/td>\n<td style=\"text-align: left;\">\u65e0\u7a77\u8303\u6570\uff1a$l_\\infty$<\/td>\n<td style=\"text-align: left;\">$max(\\mid x_i\\mid)$<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8303\u6570\u7406\u8bba\u7684\u4e00\u4e2a\u5c0f\u63a8\u8bba\u544a\u8bc9\u6211\u4eec\uff1a$l_1 \\geq l<em>2 \\geq l<\/em>\\infty$<\/p>\n<h3>Numpy<\/h3>\n<pre><code class=\"language-python\">import numpy as np\n\n# \u5411\u91cf\nx = np.arange(9) - 4\n# \u77e9\u9635\nA = x.reshape((3, 3))\nprint(A)\n# L1\u8303\u6570\nprint(np.linalg.norm(x, 1))\n# L2\u8303\u6570\nprint(np.linalg.norm(x, 2))\n# L\u6b63\u65e0\u7a77\u8303\u6570\nprint(np.linalg.norm(x, np.inf))\n# L\u8d1f\u65e0\u7a77\u8303\u6570\nprint(np.linalg.norm(x, -np.inf))\n# Frobenius\u8303\u6570\nprint(np.linalg.norm(A))<\/code><\/pre>\n<h3>Numpy<\/h3>\n<pre><code class=\"language-python\">import numpy as np\nfrom scipy import linalg\n\n# \u5411\u91cf\nx = np.arange(9) - 4\n# \u77e9\u9635\nA = x.reshape((3, 3))\nprint(A)\n# L1\u8303\u6570\nprint(linalg.norm(x,1))\n# L2\u8303\u6570\nprint(linalg.norm(x,2))\n# L\u6b63\u65e0\u7a77\u8303\u6570\nprint(linalg.norm(x,np.inf))\n# L\u8d1f\u65e0\u7a77\u8303\u6570\nprint(linalg.norm(x,-np.inf))\n# Frobenius\u8303\u6570\nprint(linalg.norm(A))<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Lp\u8303\u6570 $$ \\mid\\mid x\\mid\\midp = (\\sum{i}|x_i|^p)^{\\frac { [&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-2102","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\/2102","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=2102"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2102\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}