{"id":1485,"date":"2020-09-03T15:10:40","date_gmt":"2020-09-03T07:10:40","guid":{"rendered":"http:\/\/home.wangjianshuo.com\/cn\/?p=1485"},"modified":"2020-09-03T15:10:40","modified_gmt":"2020-09-03T07:10:40","slug":"%e5%8d%b7%e7%a7%af%e7%bd%91%e7%bb%9c-cnn-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%e4%b9%8b%e5%9b%9b%ef%bc%9a%e6%9c%80%e7%bb%88%e5%bd%a2%e6%88%90%e5%88%a4%e6%96%ad","status":"publish","type":"post","link":"https:\/\/home.wangjianshuo.com\/cn\/20200903_%e5%8d%b7%e7%a7%af%e7%bd%91%e7%bb%9c-cnn-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%e4%b9%8b%e5%9b%9b%ef%bc%9a%e6%9c%80%e7%bb%88%e5%bd%a2%e6%88%90%e5%88%a4%e6%96%ad.htm","title":{"rendered":"\u5377\u79ef\u7f51\u7edc CNN \u5b66\u4e60\u7b14\u8bb0\u4e4b\u56db\uff1a\u6700\u7ec8\u5f62\u6210\u5224\u65ad"},"content":{"rendered":"<div id=\"wechat\">\n<p style=\"text-align: center;\"><img src=\"http:\/\/home.wangjianshuo.com\/cn\/2020\/09\/picture-22.jpg\"\/><\/p>\n<p style=\"text-align: left;\"><span style=\"font-size: 15px;color: rgb(136, 136, 136);\">\u9898\u56fe\uff1a\u601d\u5357\u8def\u522b\u5885<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"color:#888888;\"><span style=\"caret-color: rgb(136, 136, 136);font-size: 15px;\">\u7ed8\u4e8e\uff1a2020\u5e744\u670817\u65e5<\/span><\/span><\/p>\n<p><a data-itemshowtype=\"0\" data-linktype=\"2\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzI0Mjg0MA==&amp;mid=2652371437&amp;idx=1&amp;sn=57a20e87ac2aaed52adfe3b0e6a1e4d8&amp;chksm=bd3fab5a8a48224c62d0ac433d1c7e1336f41f01fdcd060c0123d93f2acabf24519951f77ebf&amp;scene=21#wechat_redirect\" tab=\"innerlink\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b66\u4e60\u7b14\u8bb0\u4e4b\u4e00\uff1a\u6211\u4eec\u662f\u600e\u4e48\u8ba4\u8bc6 0 \u7684<\/a><\/p>\n<p><a data-itemshowtype=\"0\" data-linktype=\"2\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzI0Mjg0MA==&amp;mid=2652371505&amp;idx=1&amp;sn=dc38b21c72f119b9d34362791d08cb45&amp;chksm=bd3fa8868a48219016f6dbcc2149eff5128eb2231828a69aaadc152f1426fb05eb26ed95d353&amp;scene=21#wechat_redirect\" tab=\"innerlink\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b66\u4e60\u7b14\u8bb0\u4e4b\u4e8c\uff1a\u7ec6\u8282\u6d88\u5931\uff0c\u62bd\u8c61\u751f\u6210<\/a><\/p>\n<p><a data-itemshowtype=\"0\" data-linktype=\"2\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzI0Mjg0MA==&amp;mid=2652371548&amp;idx=1&amp;sn=3c56ef4fd73a714c018ba954e44bc950&amp;chksm=bd3fa8eb8a4821fd0fc757afe6e85b1989dfac9feafb0901c490f97537f600d4cf51b8b1253e&amp;scene=21#wechat_redirect\" tab=\"innerlink\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b66\u4e60\u7b14\u8bb0\u4e4b\u4e09\uff1a\u5377\u79ef\u50cf\u5377\u5730\u6bef<\/a><\/p>\n<p>\u4e0a\u4e00\u6b21\u8d70\u5230\u4e86\u5377\u79ef\u7f51\u7edc\u7684\u7b2c\u4e00\u6b65\uff0c\u5c31\u662f\u7528\u4e00\u4e2a 3&#215;3 \u7684\u5c0f\u77e9\u9635\u5c31\u50cf\u63a2\u7167\u706f\u4e00\u6837\uff0c\u628a\u56fe\u50cf\u626b\u4e00\u904d\uff0c\u5c31\u5f97\u5230\u4e86\u7b2c\u4e8c\u5c42\u7684\u7f51\u7edc\u3002<\/p>\n<p>\u7b2c\u4e00\u5c42\u5bf9\u4e8e\u9ed1\u767d\u7684\u56fe\u50cf\u53ea\u6709\u4e00\u4e2a\u6df1\u5ea6\uff08depth\uff09\uff0c\u5c31\u662f\u7070\u5ea6\u503c\uff0c\u5bf9\u4e8e\u7b2c\u4e8c\u5c42\u7f51\u7edc\u5df2\u7ecf\u589e\u52a0\u5230\u4e86 32 \u5c42\u6df1\uff0c\u5206\u522b\u5bf9\u5e94\u4e8e\u5728 32 \u4e2a\u4e0d\u540c\u7684 filter \u4e0a\u7684\u5339\u914d\u7a0b\u5ea6\u3002\u6211\u4eec\u8fd9\u6b21\u63a5\u7740\u6df1\u5165\u3002<\/p>\n<p><strong>ReLU \uff08\u706f\u6ce1\u4eae\u4e86\uff01\uff09<\/strong><\/p>\n<p>\u4e0d\u77e5\u9053\u662f\u8c01\u7528\u706f\u6ce1&#x1f4a1;\u6765\u8868\u793a\u8111\u5b50\u91cc\u9762\u7684\u4e00\u4e2a\u65b0\u4e3b\u610f\uff0c\u771f\u662f\u4e00\u4e2a\u975e\u5e38\u597d\u7684\u6bd4\u55bb\uff0c\u5c31\u662f\u5f53\u4e00\u4e2a\u60f3\u6cd5\u8bde\u751f\u7684\u65f6\u5019\uff0c\u5c31\u89c9\u5f97\u662f\u8111\u5b50\u91cc\u9762\u4ec0\u4e48\u5730\u65b9\u7684\u4e00\u4e2a\u5c0f\u706f\u6ce1\u5ffd\u7136\u4eae\u8d77\u6765\u4e86\u3002<\/p>\n<p>\u524d\u9762\u7684\u5377\u79ef\uff0c\u751f\u6210\u7684\u7ed3\u679c\u5c31\u7b97\u518d\u590d\u6742\uff0c\u4e5f\u662f\u6309\u7167\u7ebf\u6027\u51fd\u6570\u6765\u63a8\u5012\u7684\uff0c\u5c31\u662f y = a * x + b \uff0c\u518d\u600e\u4e48\u53d8\u5316\u591a\u7aef\uff0c\u90fd\u8fd8\u662f\u4e00\u4e2a\u7ebf\u6027\u51fd\u6570\u3002\u6709\u4eba\u5c31\u63d0\u51fa\u6765\u4e86\uff0c\u5927\u8111\u7684\u795e\u7ecf\u7f51\u7edc\u5e94\u8be5\u4e0d\u662f\u8fd9\u4e48\u5de5\u4f5c\u7684\u3002\u5e94\u8be5\u5f15\u5165\u4e00\u4e9b\u975e\u7ebf\u6027\u7684\u4e1c\u897f\u3002\u8fd9\u5c31\u662f ReLu \u6fc0\u6d3b\u3002\uff08ReLU = Rectified Linear Unit\uff09<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u7b80\u5355\u5f97\u5f88\uff0c\u5c31\u662f\uff1a\u5f53\u8f93\u5165\u5c0f\u4e8e 0\u00a0\u7684\u65f6\u5019\uff0c\u8f93\u51fa\u4e3a\u96f6\u3002\u4f46\u8f93\u5165\u5927\u4e8e 0 \u7684\u65f6\u5019\uff0c\u8f93\u51fa\u662f\u8fd9\u4e2a\u6570\u3002\u7528\u4ee3\u7801\u8868\u793a\u5c31\u662f\uff1a<\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"nginx\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__attribute\">y<\/span>\u00a0=\u00a0max(\u00a0<span class=\"code-snippet__number\">0<\/span>\u00a0, x )<\/span><\/code><\/pre>\n<\/section>\n<p>\u8fd9\u4e2a\u5c31\u6709\u6548\u7684\u628a\u65e0\u5173\u7684\u4fe1\u606f\u7ed9\u7b80\u5316\u548c\u5c4f\u853d\u4e86\u3002\u5bf9\u4e8e\u7ad6\u7ebf\u7684\u68c0\u6d4b\u51fd\u6570\uff0c\u5982\u679c\u6211\u6ca1\u6709\u68c0\u6d4b\u5230\u7ad6\u7ebf\uff0c\u6211\u5c31\u8f93\u51fa\u4e3a 0 \uff0c \u800c\u4e0d\u518d\u8f93\u51fa\u8d1f\u5411\u7684\u4fe1\u606f\u4e86\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u6211\u770b\u5230\u4e86\u6709\u4eba\u505a\u597d\u4e8b\uff0c\u6211\u5c31\u53eb\u51fa\u6765\uff1b\u5982\u679c\u6709\u4eba\u505a\u574f\u4e8b\uff0c\u6211\u5c31\u5f53\u6ca1\u770b\u89c1\uff0c\u4e5f\u4e0d\u4f1a\u53bb\u4e3e\u62a5\u4f60\u3002<\/p>\n<p>\u8fd9\u5c31\u5f88\u50cf\u8111\u5b50\u91cc\u9762\u7684\u90a3\u4e2a\u706f\u6ce1 &#x1f4a1;\uff0c\u5f53\u51e0\u4e2a\u8f93\u5165\u7684\u7ed3\u679c\u5408\u5e76\u8d77\u6765\u4f7f\u5f97\u8f93\u51fa\u9ad8\u8fc7\u4e00\u4e2a\u9608\u503c\u7684\u65f6\u5019\uff0c\u4e0b\u4e00\u5c42\u76f8\u5e94\u7684\u795e\u7ecf\u5143\u5c31\u88ab\u70b9\u4eae\uff08\u6fc0\u6d3b\uff09\uff0c\u5982\u679c\u6ca1\u6709\u8d85\u8fc7\u7684\u8bdd\uff0c\u5c31\u7ee7\u7eed\u6697\u6de1\u4e0b\u53bb\u3002\u8fd9\u4e2a\u5f88\u7b80\u5355\u7684\u51fd\u6570\u7ed9\u6574\u4e2a\u7cfb\u7edf\u5e26\u6765\u4e86\u96be\u5f97\u7684\u975e\u7ebf\u6027\uff0c\u5c31\u53ef\u4ee5\u6709\u4e00\u4e9b\u903b\u8f91\u8fd0\u7b97\u7684\u611f\u89c9\u5728\u91cc\u9762\u4e86\u3002<\/p>\n<p><strong>\u6211\u4eec\u6784\u5efa\u7684\u56db\u5c42\u795e\u7ecf\u7f51\u7edc<\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\">model = Sequential()<\/span><\/code><code><span class=\"code-snippet_outer\">model.<span class=\"code-snippet__keyword\">add<\/span>(Conv2D(<span class=\"code-snippet__number\">32<\/span>, kernel_size=(<span class=\"code-snippet__number\">3<\/span>, <span class=\"code-snippet__number\">3<\/span>), activation=<span class=\"code-snippet__string\">'relu'<\/span>, input_shape=(<span class=\"code-snippet__number\">28<\/span>, <span class=\"code-snippet__number\">28<\/span>, <span class=\"code-snippet__number\">1<\/span>)))<\/span><\/code><\/pre>\n<\/section>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u5c31\u662f\u5efa\u8bbe\u4e86\u4e00\u4e2a Conv2D \u7684\u6a21\u578b\uff0c\u8fd9\u4e2a\u6a21\u578b\u7684 filter \u6570\u91cf\u662f 32\uff0c kernel_size\uff0c\u5c31\u662f\u8fd9\u4e2a filter \u7684\u5927\u5c0f\uff0c\u662f 3 x 3 \uff0c \u6fc0\u6d3b\u51fd\u6570\u4f7f\u7528\u4e86 relu \uff0c\u5e76\u4e14\u63a5\u53d7\u4e00\u4e2a\u8f93\u5165\u4e3a 28 x 28 x 1 \u7684\u77e9\u9635\uff08\u5c31\u662f\u90a3\u4e2a\u56fe\u50cf\uff09\uff0c\u8f93\u51fa\u4e00\u4e2a 26 \u00a0x 26 x 32 \u7684\u77e9\u9635\u3002\u5bbd\u548c\u9ad8\u4ece 28&#215;28 \u53d8\u6210\u4e86 26&#215;26 \u662f\u56e0\u4e3a\u7528\u4e00\u4e2a 3&#215;3 \u7684\u77e9\u9635\u5411\u53f3\u632a\u7684\u65f6\u5019\u81ea\u7136\u4f1a\u5931\u53bb\u6700\u5de6\u548c\u6700\u53f3\u7684\u4e24\u5217\uff0c\u5c31\u50cf\u4e00\u4e2a 4&#215;4 \u7684\u77e9\u9635\u7528\u4e00\u4e2a 3&#215;3 \u7684\u77e9\u9635\u53bb\u6ed1\u52a8\u7684\u8bdd\u53ea\u80fd\u6ed1\u52a8\u4e00\u683c\uff0c\u7ed3\u679c\u53d8\u6210 2&#215;2 \u7684\u77e9\u9635\u4e00\u6837\u3002<\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\">model.<span class=\"code-snippet__keyword\">add<\/span>(MaxPooling2D(pool_size=(<span class=\"code-snippet__number\">2<\/span>,\u00a0<span class=\"code-snippet__number\">2<\/span>)))<\/span><\/code><\/pre>\n<\/section>\n<p>\u6211\u4eec\u7ee7\u7eed\u89e3\u91ca\u4ee3\u7801\u3002\u4e0b\u4e00\u4e2a\u5c31\u662f MaxPooling2D \u7684\u529f\u80fd\u3002\u8fd9\u4e2a\u66f4\u7b80\u5355\u7684\u4e86\u3002\u5c31\u662f\u62ff\u4e00\u4e2a\uff082\uff0c2\uff09\u7684\u533a\u57df\uff0c\u627e\u5230\u5176\u4e2d\u6700\u5927\u7684\u90a3\u4e2a\u6570\uff0c\u8f93\u51fa\u51fa\u6765\uff0c\u628a\u539f\u6765\u56db\u4e2a\u50cf\u7d20\u7684\u4f4d\u7f6e\u5408\u5e76\u6210\u4e00\u4e2a\u50cf\u7d20\uff0c\u5e76\u4e14\u628a\u8fd9\u4e2a\u6570\u5b57\u586b\u8fdb\u53bb\u3002\u8fd9\u4e2a\u5c31\u662f\u7b80\u5355\u7c97\u66b4\u7684\u628a\u4e00\u4e2a 26&#215;26 \u7684\u77e9\u9635\u7f29\u6210\u4e86\u4e00\u4e2a 13&#215;13 \u7684\u77e9\u9635\u3002<\/p>\n<p>\u4ece\u903b\u8f91\u4e0a\u8bb2\uff0c\u8fd9\u5c31\u662f\u5ffd\u7565\u7ec6\u8282\u7684\u8fc7\u7a0b\u3002\u6211\u4eec\u770b\u4e00\u4e2a\u6570\u5b57\u7684\u65f6\u5019\uff0c\u9690\u9690\u7ea6\u7ea6\u7684\u89c9\u5f97\u5de6\u4e0a\u89d2\u6709\u8f86\u8f66\uff0c\u81f3\u4e8e\u5b83\u7cbe\u786e\u7684\u5728\u4ec0\u4e48\u4f4d\u7f6e\uff0c\u957f\u4ec0\u4e48\u6837\u5b50\uff0c\u4e0d\u91cd\u8981\uff0c\u91cd\u8981\u7684\u662f\uff0c \u5de6\u4e0a\u89d2\u6709\u4e00\u8f86\u8f66\u3002\u4ed6\u5c31\u662f\u628a\u5f97\u51fa\u7684 32 \u4e2a\u56fe\u50cf\u7684\u5927\u5c0f\u90fd\u7f29\u5c0f\u4e00\u534a\uff0c\u4f46\u662f\u4fe1\u606f\u90fd\u4fdd\u7559\uff08\u5c31\u662f\u6700\u5927\u7684\uff0c\u5df2\u7ecf\u627e\u5230\u7684\u90a3\u4e2a\u6a21\u5f0f\uff09\u3002<\/p>\n<p><strong>Flattern<\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\">model.<span class=\"code-snippet__keyword\">add<\/span>(Flatten())<\/span><\/code><\/pre>\n<\/section>\n<p>\u8fd9\u4e2a\u4e00\u4e2a\u6bd4\u4e00\u4e2a\u7b80\u5355\uff0c\u5c31\u662f\u628a\u6240\u6709\u7684\u6570\u5b57\u4ece\u77e9\u9635\u6392\u6210\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u3002\u524d\u9762\u7684\u8f93\u51fa\u662f\u4e00\u4e2a 13 x 13 x 32 \u7684\u4e00\u4e2a\u77e9\u9635\uff0c\u901a\u8fc7\u8fd9\u4e00\u5c42\uff0c\u53d8\u6210\u4e86\u4e00\u4e2a 5408 \u4e2a\u6570\u5b57\u6570\u7ec4\u3002\u5c31\u50cf\u628a\u9ebb\u5c06\u684c\u4e2d\u95f4\u7684\u4e00\u5806\u9ebb\u5c06\u5728\u81ea\u5df1\u9762\u524d\u4e00\u5b57\u6392\u5f00\u90a3\u6837\u3002<\/p>\n<p><strong>\u5168\u8054\u63a5\u5c42<\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\">model.<span class=\"code-snippet__keyword\">add<\/span>(Dense(<span class=\"code-snippet__number\">10<\/span>, activation=<span class=\"code-snippet__string\">'softmax'<\/span>))<\/span><\/code><\/pre>\n<\/section>\n<p>\u6700\u540e\u7684\u8fd9\u4e00\u4e2a\u5c42\u53eb\u505a\u5168\u8054\u63a5\u5c42\uff0c\u5c31\u662f\u628a\u524d\u9762\u76845408\u4e2a\u6570\u5b57\u548c\u6700\u7ec8\u7ed3\u679c\u768410\u4e2a\u6570\u5b57\u505a\u4e00\u4e2a\u6bcf\u4e00\u4e2a\u8282\u70b9\u548c\u53e6\u5916\u4e00\u5c42\u7684\u6bcf\u4e00\u4e2a\u90fd\u8fde\u63a5\u8d77\u6765\uff0c\u627e\u5230\u4e00\u4e2a\u7cfb\u6570\uff0c\u627e\u5230 y = a * x + b \u8fd9\u6837\u7684\u5173\u7cfb\u3002<\/p>\n<p>\u5c31\u662f\u8bf4\uff0c\u5bf9\u4e8e\u7ed3\u679c\u7684\u7b2c\u4e00\u4e2a\u6570\u5b57\uff0c\u662f\u524d\u97625408\u4e2a\u6570\u5b57\u548c5408\u4e2a\u7cfb\u6570\uff08a1, a2, a3, &#8230;, a5048)\u00a0\u76f8\u4e58\u5e76\u4e14\u628a\u7ed3\u679c\u76f8\u52a0\uff0c\u518d\u52a0\u4e0a\u4e00\u4e2a\u6570\u5b57\uff08b\uff09\u5f97\u6765\u3002\u8fd9\u4e00\u5c42\u7684\u53c2\u6570\u6700\u591a\uff0c\u9700\u8981\uff085408 + 1\uff09* 10 = 54090 \u4e2a\u53c2\u6570\u624d\u53ef\u4ee5\u5b8c\u6210\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u524d\u9762\u7684 \uff083 x 3 + 1\uff09x 32 =\u00a0 320\u4e2a\u53c2\u6570\u7b97\u662f\u7cbe\u7b80\u5f97\u4e0d\u5f97\u4e86\u3002<\/p>\n<p>\u8fd9\u4e00\u5c42\u6700\u7ec8\u662f10\u4e2a\u6570\u5b57\uff0c\u5bf9\u5e94\u7740\u7b54\u6848\u7684\u5341\u4e2a\u6570\u5b57\uff0c\u4f5c\u4e3a\u8fd9\u4e2a\u6a21\u578b\u7684\u7b2c\u56db\u5c42\uff0c\u4e5f\u662f\u6700\u540e\u4e00\u5c42\uff0c\u7ecf\u8fc7\u4e00\u4e2a\u53eb\u505a softmax \u7684\u6fc0\u6d3b\u51fd\u6570\uff0c\u5b83\u7684\u8f93\u51fa\u662f\u4e00\u4e2a\u5341\u4e2a\u6570\u7684\u6570\u7ec4\uff0c\u8fd9\u5341\u4e2a\u6570\u5b57\u5206\u522b\u90fd\u662f0-1\u4e4b\u95f4\u7684\u4e00\u4e2a\u6570\u5b57\uff0c\u4ed6\u4eec\u7684\u52a0\u548c\u7b49\u4e8e 1 \uff0c \u6bcf\u4e2a\u6570\u5b57\u90fd\u5bf9\u5e94\u76f8\u5e94\u4f4d\u7f6e\u7684\u53ef\u80fd\u6027\u3002\u6bd4\u5982\u4e0a\u4e00\u7bc7\u7684\u7ed3\u679c\uff0c\u5c31\u4f1a\u662f 2 \u5bf9\u5e94\u7684\u6570\u5b57\u975e\u5e38\u9ad8\uff08\u5c31\u662f\u7535\u8111\u8ba4\u4e3a\u5f88\u6709\u53ef\u80fd\u662f 2 \uff09\uff0c\u800c\u5176\u4ed6\u7684\u90fd\u5f88\u5c0f\u3002<\/p>\n<p><strong>\u8bad\u7ec3\u51fd\u6570<\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">model.compile(optimizer=<span class=\"code-snippet__string\">'adam'<\/span>,\u00a0metrics=[<span class=\"code-snippet__string\">'accuracy'<\/span>],\u00a0loss=<span class=\"code-snippet__string\">'sparse_categorical_crossentropy'<\/span>)<\/span><\/code><\/pre>\n<\/section>\n<p>\u73b0\u5728\u6211\u4eec\u5c31\u5230\u4e86\u6838\u5fc3\u76847\u884c\u4ee3\u7801\u7684\u6700\u540e\u4e09\u884c\u4e86\u3002\u524d\u56db\u884c\u5206\u522b\u6784\u5efa\u4e86\u56db\u5c42\u7f51\u7edc\uff0c\u6700\u540e\u5c31\u5f00\u59cb\u8bad\u7ec3\u8fd9\u4e2a\u7f51\u7edc\u4e86\u3002<\/p>\n<p>compile \u90a3\u4e00\u884c\u7ed9\u51fa\u4e86\u4f18\u5316\u5668\uff0closs\u51fd\u6570\u8fd8\u6709\u5982\u4f55\u8861\u91cf\u597d\u574f\u7684\u51fd\u6570\u3002\u8fd9\u4e9b\u5bf9\u4e8e\u521d\u5b66\u8005\u53ef\u4ee5\u6682\u65f6\u4e0d\u8003\u8651\uff0c\u5c31\u5148\u7167\u732b\u753b\u864e\u5c31\u597d\u4e86\u3002<\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">model.summary()<\/span><\/code><\/pre>\n<\/section>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u628a\u73b0\u5728\u6784\u5efa\u7684\u8fd9\u4e2a\u7f51\u7edc\u7684\u6458\u8981\u6253\u5370\u51fa\u6765<\/p>\n<p style=\"font-stretch: normal;font-size: 18px;line-height: normal;font-family: Courier;color: rgb(59, 35, 34);background-color: rgb(215, 211, 183);\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"markdown\"><code><span class=\"code-snippet_outer\">Model: \"sequential\"<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__section\">Layer (type)                 Output Shape              Param #   <\/span><\/span><\/code><code><span class=\"code-snippet_outer\">=================================================================<\/span><\/code><code><span class=\"code-snippet_outer\">conv2d (Conv2D)              (None, 26, 26, 32)        320       <\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">max_pooling2d (MaxPooling2D) (None, 13, 13, 32)        0         <\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">flatten (Flatten)            (None, 5408)              0         <\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><span class=\"code-snippet__strong\">_____<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__section\">dense (Dense)                (None, 10)                54090     <\/span><\/span><\/code><code><span class=\"code-snippet_outer\">=================================================================<\/span><\/code><code><span class=\"code-snippet_outer\">Total params: 54,410<\/span><\/code><code><span class=\"code-snippet_outer\">Trainable params: 54,410<\/span><\/code><code><span class=\"code-snippet_outer\">Non-trainable\u00a0params:\u00a0<\/span><\/code><\/pre>\n<\/section>\n<p>\u4ece\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u6e05\u6670\u7684\u770b\u5230\uff0c\u7b2c\u4e00\u5c42\uff0c\u8f93\u5165\u4e00\u4e2a 28x28x1 \u7684\u56fe\u50cf\uff0c\u8f93\u51fa\u4e00\u4e2a26x26x32 \u7684\u56fe\u50cf\u3002\u800c\u6df1\u5ea6\u4ece1\u53d8\u523032\u5c31\u662f\u4ece\u7070\u5ea6\u8fd9\u4e00\u4e2a\u7ef4\u5ea6\u53d8\u6210\u4e8632\u4e0d\u540c\u7684\u95ee\u9898\u7684\u7b54\u6848\uff08\u6bd4\u5982\u6709\u6ca1\u6709\u7ad6\u7ebf\u8fd9\u6837\u7684\u95ee\u9898\uff09\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u7684 MaxPooling \u5c42\uff0c\u5982\u6211\u4eec\u521a\u624d\u6240\u8bf4\uff0c\u5728\u6df1\u5ea6 32 \u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u628a\u6bcf\u4e00\u5c42\u90fd\u4ece 26&#215;26 \u7b80\u5316\u6210\u4e86 13&#215;13 \u3002<\/p>\n<p>\u5728\u4e0b\u9762\u7684 Flattern \u5c42\uff0c\u628a13x13x32\u538b\u6241\u6210\u4e00\u4e2a\u957f\u5ea6\u4e3a 5408 \u7684\u6570\u7ec4\u3002<\/p>\n<p>\u6700\u540e\u4e00\u5c42\u518d\u628a\u8fd9\u4e2a\u6570\u7ec4\u53d8\u6210\u957f\u5ea6\u4e3a 10 \u7684\u6570\u7ec4\uff0c\u5206\u522b\u5bf9\u5e94\u4e8e\u7ed3\u679c\u7684 0 &#8211; 9 \u3002<\/p>\n<p><strong>\u5f00\u59cb\u8bad\u7ec3<\/strong><\/p>\n<p><strong><\/strong><\/p>\n<p>\u5230\u4e86\u73b0\u5728\uff0c\u7f51\u7edc\u5df2\u7ecf\u642d\u597d\u4e86\uff0c\u4f46\u552f\u4e00\u7684\u95ee\u9898\u662f\uff0c\u91cc\u9762\u6240\u6709\u7684\u53c2\u6570\u90fd\u662f 0 &#8211; 1 \u4e4b\u95f4\u7684\u968f\u673a\u6570\uff0c\u7528\u4e00\u4e2a\u968f\u673a\u6570\u6784\u6210\u7684\u7f51\u7edc\u80af\u5b9a\u51c6\u786e\u7387\u5dee\u5f97\u4e00\u584c\u7cca\u6d82\u4e86\u3002\u7528\u4e00\u4e2a\u968f\u673a\u6570\u4f5c\u4e3a\u53c2\u6570\u7684\u7f51\u7edc\uff0c\u5f53\u4f60\u8f93\u5165\u4e00\u4e2a\u56fe\u50cf\uff0c\u5b83\u4e00\u5b9a\u4e5f\u53ef\u4ee5\u8f93\u51fa\u4e00\u4e2a\u6570\u5b57\uff0c\u4f46\u8fd9\u4e2a\u6570\u5b57 10 \u6b21\u6709 9 \u6b21\u662f\u9519\u7684\uff0c\u5bf9\u7684\u4e00\u6b21\u4e5f\u662f\u778e\u732b\u78b0\u5230\u6b7b\u8017\u5b50\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u968f\u673a\u6570\uff0c\u63a5\u4e0b\u6765\u8fd9\u4e00\u53e5\u8bdd\uff0c\u624d\u662f\u6700\u91cd\u8981\u7684\u4e00\u53e5\u8bdd\uff0c\u5c31\u662f\u5f00\u59cb\u201c\u8bad\u7ec3\u201d\u4e86\u3002<\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\"><code><span class=\"code-snippet_outer\">model.fit(x_train,\u00a0y_train,\u00a0epochs=20)<\/span><\/code><\/pre>\n<\/section>\n<p>\u8fd9\u4e2a\u51fd\u6570\u628a60000\u4e2a x_train \u5305\u542b\u7684\u56fe\u50cf\uff0c\u8fd8\u6709 60000 \u4e2a y_train \u4ee3\u8868\u7684\u6b63\u786e\u7b54\u6848\u4ea4\u7ed9\u7f51\u7edc\u3002\u521a\u5f00\u59cb\u7684\u65f6\u5019\uff0c\u7b54\u6848\u80af\u5b9a\u662f\u9519\u7684\u3002\u4f46\u662f\u795e\u7ecf\u7f51\u7edc\u901a\u8fc7\u9519\u7684\u65b9\u5411\uff08\u7ed3\u679c\u592a\u5927\u4e86\u8fd8\u662f\u592a\u5c0f\u4e86\uff09\u53bb\u53cd\u8fc7\u53bb\u8c03\u6574\u4e0a\u4e00\u5c42\u7f51\u7edc\u7684\u53c2\u6570\uff0c\u7136\u540e\u518d\u8fdb\u4e00\u6b65\u8c03\u6574\u518d\u4e0a\u4e00\u5c42\u7684\u53c2\u6570\uff0c\u76f4\u5230\u75286000\u7ec4\u6570\u636e\u628a\u8fd9 54,410 \u4e2a\u53c2\u6570\u8c03\u6574\u5230\u7cbe\u786e\u5ea6\u6700\u9ad8\u7684\u7a0b\u5ea6\u3002\u5230\u4e86\u8bad\u7ec3\u7684\u672b\u671f\uff0c\u57fa\u672c\u4e0a\u4e0a\u4e00\u6b21\u8bad\u7ec3\u7684\u8fd9\u4e9b\u53c2\u6570\u5df2\u7ecf\u53ef\u4ee5\u8ba9\u4e0b\u4e00\u6b21\u8f93\u5165\u7684\u53c2\u6570\u4ee5\u6781\u5927\u7684\u53ef\u80fd\u6027\uff0899%\u4ee5\u4e0a\uff09\u548c\u6b63\u786e\u7b54\u6848\u76f8\u540c\u4e86\uff0c\u8fd9\u4e2a\u8bad\u7ec3\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<p>\u4e0b\u4e00\u6b21\uff0c\u6211\u4eec\u4f1a\u518d\u628a\u4e0a\u9762\u8bf4\u7684\u8fd9\u4e2a\u8fc7\u7a0b\u7528\u56fe\u50cf\u53ef\u89c6\u5316\u51fa\u6765\uff0c\u7136\u540e\u518d\u7ee7\u7eed\u7528\u6bd4\u55bb\u7684\u65b9\u6cd5\u6765\u5b8f\u89c2\u7684\u7406\u89e3\uff0c\u8ba1\u7b97\u673a\u5230\u5e95\u662f\u600e\u4e48\u8ba4\u8bc6\u6570\u5b57\u7684\u3002<\/p>\n<p>\u540e\u53f0\u56de\u590d AI \u53ef\u4ee5\u83b7\u5f97\u6ca1\u6709\u53d1\u8868\u7684AI\u76f8\u5173\u7684\u6587\u7ae0\u548c\u4ee3\u7801\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u56fe\uff1a\u601d\u5357\u8def\u522b\u5885 \u7ed8\u4e8e\uff1a2020\u5e744\u670817\u65e5 \u5b66\u4e60\u7b14\u8bb0\u4e4b\u4e00\uff1a\u6211\u4eec\u662f\u600e\u4e48\u8ba4\u8bc6 0 \u7684 \u5b66\u4e60\u7b14\u8bb0\u4e4b\u4e8c\uff1a\u7ec6\u8282\u6d88\u5931\uff0c\u62bd &hellip; <a href=\"https:\/\/home.wangjianshuo.com\/cn\/20200903_%e5%8d%b7%e7%a7%af%e7%bd%91%e7%bb%9c-cnn-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%e4%b9%8b%e5%9b%9b%ef%bc%9a%e6%9c%80%e7%bb%88%e5%bd%a2%e6%88%90%e5%88%a4%e6%96%ad.htm\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5377\u79ef\u7f51\u7edc CNN \u5b66\u4e60\u7b14\u8bb0\u4e4b\u56db\uff1a\u6700\u7ec8\u5f62\u6210\u5224\u65ad<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/posts\/1485"}],"collection":[{"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/comments?post=1485"}],"version-history":[{"count":1,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/posts\/1485\/revisions"}],"predecessor-version":[{"id":1486,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/posts\/1485\/revisions\/1486"}],"wp:attachment":[{"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/media?parent=1485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/categories?post=1485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/home.wangjianshuo.com\/cn\/wp-json\/wp\/v2\/tags?post=1485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}