{"id":641,"date":"2023-11-18T13:04:32","date_gmt":"2023-11-18T05:04:32","guid":{"rendered":"http:\/\/ai.gitpp.com\/?p=641"},"modified":"2023-11-18T13:04:32","modified_gmt":"2023-11-18T05:04:32","slug":"github%e4%b8%8a%e9%ab%98%e8%b5%9e%ef%bc%9a-tensorflow-%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"http:\/\/ai.gitpp.com\/index.php\/2023\/11\/18\/github%e4%b8%8a%e9%ab%98%e8%b5%9e%ef%bc%9a-tensorflow-%e7%a4%ba%e4%be%8b\/","title":{"rendered":"GitHub\u4e0a\u9ad8\u8d5e\uff1a TensorFlow \u793a\u4f8b"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/mp.weixin.qq.com\/s\/17G1sdx1JkDhwc7admX8fw\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6559\u7a0b\u7d22\u5f15<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">0 &#8211; \u5148\u51b3\u6761\u4ef6<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u673a\u5668\u5b66\u4e60\u7b80\u4ecb\u3002<\/li>\n\n\n\n<li>MNIST \u6570\u636e\u96c6\u7b80\u4ecb\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">1 &#8211; \u7b80\u4ecb<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f60\u597d\u4e16\u754c\uff08\u7b14\u8bb0\u672c\uff09\u3002\u975e\u5e38\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 TensorFlow 2.0+ \u6253\u5370\u201chello world\u201d\u3002<\/li>\n\n\n\n<li>\u57fa\u672c\u64cd\u4f5c\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4e00\u4e2a\u6db5\u76d6 TensorFlow 2.0+ \u57fa\u672c\u64cd\u4f5c\u7684\u7b80\u5355\u793a\u4f8b\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2 &#8211; \u57fa\u672c\u6a21\u578b<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7ebf\u6027\u56de\u5f52\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u5b9e\u73b0\u7ebf\u6027\u56de\u5f52\u3002<\/li>\n\n\n\n<li>\u903b\u8f91\u56de\u5f52\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u5b9e\u73b0\u903b\u8f91\u56de\u5f52\u3002<\/li>\n\n\n\n<li>Word2Vec\uff08\u8bcd\u5d4c\u5165\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u4ece\u7ef4\u57fa\u767e\u79d1\u6570\u636e\u6784\u5efa\u8bcd\u5d4c\u5165\u6a21\u578b (Word2Vec)\u3002<\/li>\n\n\n\n<li>GBDT\uff08\u68af\u5ea6\u63d0\u5347\u51b3\u7b56\u6811\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u5b9e\u73b0\u68af\u5ea6\u63d0\u5347\u51b3\u7b56\u6811\uff0c\u4ee5\u4f7f\u7528 Boston Housing \u6570\u636e\u96c6\u9884\u6d4b\u623f\u5c4b\u4ef7\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3 &#8211; \u795e\u7ecf\u7f51\u7edc<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u76d1\u7763<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b80\u5355\u795e\u7ecf\u7f51\u7edc\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0\u201c\u5c42\u201d\u548c\u201c\u6a21\u578b\u201dAPI \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u795e\u7ecf\u7f51\u7edc\u6765\u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n\n\n\n<li>\u7b80\u5355\u795e\u7ecf\u7f51\u7edc\uff08\u4f4e\u7ea7\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u7528\u4e8e\u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u7684\u7b80\u5355\u795e\u7ecf\u7f51\u7edc\u7684\u539f\u59cb\u5b9e\u73b0\u3002<\/li>\n\n\n\n<li>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+\u201c\u5c42\u201d\u548c\u201c\u6a21\u578b\u201dAPI \u6784\u5efa\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6765\u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n\n\n\n<li>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08\u4f4e\u7ea7\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u7528\u4e8e\u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u539f\u59cb\u5b9e\u73b0\u3002<\/li>\n\n\n\n<li>\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\uff08LSTM\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0\u201c\u5c42\u201d\u548c\u201c\u6a21\u578b\u201dAPI \u6784\u5efa\u5faa\u73af\u795e\u7ecf\u7f51\u7edc (LSTM) \u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n\n\n\n<li>\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08LSTM\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+\u201c\u5c42\u201d\u548c\u201c\u6a21\u578b\u201dAPI \u6784\u5efa\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc (LSTM) \u4ee5\u5bf9 MNIST \u6570\u5b57\u6570\u636e\u96c6\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n\n\n\n<li>\u52a8\u6001\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08LSTM\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+\u201c\u5c42\u201d\u548c\u201c\u6a21\u578b\u201dAPI \u6784\u5efa\u4e00\u4e2a\u5faa\u73af\u795e\u7ecf\u7f51\u7edc (LSTM)\uff0c\u6267\u884c\u52a8\u6001\u8ba1\u7b97\u4ee5\u5bf9\u53ef\u53d8\u957f\u5ea6\u7684\u5e8f\u5217\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\">\u65e0\u76d1\u7763<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u52a8\u7f16\u7801\u5668\uff08\u7b14\u8bb0\u672c\uff09\u3002\u6784\u5efa\u4e00\u4e2a\u81ea\u52a8\u7f16\u7801\u5668\u5c06\u56fe\u50cf\u7f16\u7801\u5230\u8f83\u4f4e\u7ef4\u5ea6\u5e76\u91cd\u65b0\u6784\u5efa\u5b83\u3002<\/li>\n\n\n\n<li>DCGAN\uff08\u6df1\u5ea6\u5377\u79ef\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u6784\u5efa\u6df1\u5ea6\u5377\u79ef\u751f\u6210\u5bf9\u6297\u7f51\u7edc (DCGAN) \u4ee5\u4ece\u566a\u58f0\u4e2d\u751f\u6210\u56fe\u50cf\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4 &#8211; \u516c\u7528\u4e8b\u4e1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4fdd\u5b58\u548c\u6062\u590d\u6a21\u578b\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u4fdd\u5b58\u548c\u6062\u590d\u6a21\u578b\u3002<\/li>\n\n\n\n<li>\u6784\u5efa\u81ea\u5b9a\u4e49\u5c42\u548c\u6a21\u5757\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4e86\u89e3\u5982\u4f55\u6784\u5efa\u60a8\u81ea\u5df1\u7684\u5c42\/\u6a21\u5757\u5e76\u5c06\u5176\u96c6\u6210\u5230 TensorFlow 2.0+ \u6a21\u578b\u4e2d\u3002<\/li>\n\n\n\n<li>\u5f20\u91cf\u677f\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0+ \u5f20\u91cf\u677f\u8ddf\u8e2a\u548c\u53ef\u89c6\u5316\u795e\u7ecf\u7f51\u7edc\u8ba1\u7b97\u56fe\u3001\u6307\u6807\u3001\u6743\u91cd\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">5 &#8211; \u6570\u636e\u7ba1\u7406<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52a0\u8f7d\u548c\u89e3\u6790\u6570\u636e\uff08\u7b14\u8bb0\u672c\uff09\u3002\u4f7f\u7528 TensorFlow 2.0 \u6784\u5efa\u9ad8\u6548\u7684\u6570\u636e\u7ba1\u9053\uff08Numpy \u6570\u7ec4\u3001\u56fe\u50cf\u3001CSV \u6587\u4ef6\u3001\u81ea\u5b9a\u4e49\u6570\u636e\u7b49\uff09\u3002<\/li>\n\n\n\n<li>\u6784\u5efa\u5e76\u52a0\u8f7d TFRecords\uff08\u7b14\u8bb0\u672c\uff09\u3002\u5c06\u6570\u636e\u8f6c\u6362\u4e3a TFRecords \u683c\u5f0f\uff0c\u5e76\u4f7f\u7528 TensorFlow 2.0+ \u52a0\u8f7d\u5b83\u4eec\u3002<\/li>\n\n\n\n<li>\u56fe\u50cf\u53d8\u6362\uff08\u5373\u56fe\u50cf\u589e\u5f3a\uff09\uff08\u7b14\u8bb0\u672c\uff09\u3002\u901a\u8fc7 TensorFlow 2.0+ \u5e94\u7528\u5404\u79cd\u56fe\u50cf\u589e\u5f3a\u6280\u672f\uff0c\u751f\u6210\u7528\u4e8e\u8bad\u7ec3\u7684\u626d\u66f2\u56fe\u50cf\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6 &#8211; \u786c\u4ef6<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u591a GPU \u8bad\u7ec3\uff08\u7b14\u8bb0\u672c\uff09\u3002\u5728 CIFAR-10 \u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u5177\u6709\u591a\u4e2a GPU \u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5177\u4f53\u4ee3\u7801\u89c1<\/p>\n\n\n\n<p>http:\/\/www.gitpp.com\/yuanzhongqiao\/TensorFlow-Examples<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/ciaOAxzQ9MXIoYbV7sm1r2zu5cia4aXA5uRTcicy1qO09WzcS7ISxApn8sBayuQnic6DwgwY5CiapibczHvaCLxXMUGQ\/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1\" alt=\"\u56fe\u7247\" \/><\/figure>\n\n\n\n<p><strong>\u673a\u5668\u5b66\u4e60\u7b80\u4ecb&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u673a\u5668\u5b66\u4e60\u7684\u4e3b\u8981\u7814\u7a76\u5185\u5bb9\u6db5\u76d6\u4e86\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n\n\n\n<p>1. \u76d1\u7763\u5b66\u4e60\uff1a\u76d1\u7763\u5b66\u4e60\u662f\u4e00\u79cd\u8bad\u7ec3\u7b97\u6cd5\uff0c\u901a\u8fc7\u4f7f\u7528\u6807\u8bb0\u7684\u6570\u636e\u96c6\u6765\u5b66\u4e60\u8f93\u5165\u548c\u8f93\u51fa\u4e4b\u95f4\u7684\u6620\u5c04\u5173\u7cfb\u3002\u5e38\u89c1\u7684\u76d1\u7763\u5b66\u4e60\u4efb\u52a1\u5305\u62ec\u5206\u7c7b\u3001\u56de\u5f52\u3001\u805a\u7c7b\u7b49\u3002<\/p>\n\n\n\n<p>2. \u65e0\u76d1\u7763\u5b66\u4e60\uff1a\u4e0e\u76d1\u7763\u5b66\u4e60\u76f8\u53cd\uff0c\u65e0\u76d1\u7763\u5b66\u4e60\u7b97\u6cd5\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4e0d\u9700\u8981\u6807\u8bb0\u6570\u636e\u3002\u65e0\u76d1\u7763\u5b66\u4e60\u7684\u76ee\u6807\u662f\u53d1\u73b0\u6570\u636e\u4e2d\u7684\u9690\u85cf\u7ed3\u6784\u6216\u89c4\u5f8b\uff0c\u4f8b\u5982\u805a\u7c7b\u3001\u964d\u7ef4\u3001\u5f02\u5e38\u68c0\u6d4b\u7b49\u3002<\/p>\n\n\n\n<p>3. \u5f3a\u5316\u5b66\u4e60\uff1a\u5f3a\u5316\u5b66\u4e60\u662f\u4e00\u79cd\u901a\u8fc7\u8ba9\u667a\u80fd\u4f53\u4e0e\u73af\u5883\u4e92\u52a8\u6765\u5b66\u4e60\u6700\u4f18\u7b56\u7565\u7684\u7b97\u6cd5\u3002\u667a\u80fd\u4f53\u6839\u636e\u5f53\u524d\u72b6\u6001\u91c7\u53d6\u884c\u52a8\uff0c\u6839\u636e\u73af\u5883\u53cd\u9988\u8c03\u6574\u7b56\u7565\uff0c\u4ee5\u5b9e\u73b0\u957f\u671f\u7d2f\u79ef\u5956\u52b1\u7684\u6700\u5927\u5316\u3002<\/p>\n\n\n\n<p>4. \u6df1\u5ea6\u5b66\u4e60\uff1a\u6df1\u5ea6\u5b66\u4e60\u662f\u4e00\u79cd\u57fa\u4e8e\u795e\u7ecf\u7f51\u7edc\u7684\u673a\u5668\u5b66\u4e60\u65b9\u6cd5\uff0c\u53ef\u4ee5\u81ea\u52a8\u5b66\u4e60\u590d\u6742\u7684\u6570\u636e\u8868\u793a\u3002\u6df1\u5ea6\u5b66\u4e60\u5728\u5f88\u591a\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u6210\u679c\uff0c\u5982\u8ba1\u7b97\u673a\u89c6\u89c9\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u3002<\/p>\n\n\n\n<p>5. \u7279\u5f81\u5de5\u7a0b\uff1a\u7279\u5f81\u5de5\u7a0b\u662f\u6307\u4ece\u539f\u59cb\u6570\u636e\u4e2d\u63d0\u53d6\u6709\u7528\u7279\u5f81\u7684\u8fc7\u7a0b\u3002\u5b83\u662f\u673a\u5668\u5b66\u4e60\u6a21\u578b\u6027\u80fd\u7684\u5173\u952e\u56e0\u7d20\uff0c\u56e0\u4e3a\u5408\u9002\u7684\u7279\u5f81\u80fd\u591f\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\u3002<\/p>\n\n\n\n<p>6. \u6a21\u578b\u9009\u62e9\u4e0e\u8bc4\u4f30\uff1a\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6a21\u578b\u9009\u62e9\u662f\u6307\u4ece\u591a\u4e2a\u5019\u9009\u6a21\u578b\u4e2d\u6311\u9009\u51fa\u4e00\u4e2a\u6700\u4f73\u6a21\u578b\uff0c\u800c\u6a21\u578b\u8bc4\u4f30\u5219\u662f\u5bf9\u6a21\u578b\u6027\u80fd\u8fdb\u884c\u91cf\u5316\u8bc4\u4ef7\u3002\u5e38\u7528\u7684\u8bc4\u4f30\u6307\u6807\u5305\u62ec\u51c6\u786e\u7387\u3001\u7cbe\u786e\u7387\u3001\u53ec\u56de\u7387\u3001F1 \u5206\u6570\u7b49\u3002<\/p>\n\n\n\n<p>7. \u96c6\u6210\u5b66\u4e60\uff1a\u96c6\u6210\u5b66\u4e60\u662f\u4e00\u79cd\u5c06\u591a\u4e2a\u5f31\u5b66\u4e60\u5668\u7ec4\u5408\u8d77\u6765\uff0c\u4ee5\u63d0\u9ad8\u6574\u4f53\u9884\u6d4b\u6027\u80fd\u7684\u65b9\u6cd5\u3002\u5e38\u89c1\u7684\u96c6\u6210\u5b66\u4e60\u65b9\u6cd5\u6709 Bagging\u3001Boosting\u3001Stacking \u7b49\u3002<\/p>\n\n\n\n<p>8. \u673a\u5668\u5b66\u4e60\u4f18\u5316\u4e0e\u4f18\u5316\u7b97\u6cd5\uff1a\u673a\u5668\u5b66\u4e60\u4f18\u5316\u662f\u6307\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u8c03\u6574\u6a21\u578b\u53c2\u6570\uff0c\u4ee5\u63d0\u9ad8\u6a21\u578b\u6027\u80fd\u7684\u8fc7\u7a0b\u3002\u5e38\u7528\u7684\u4f18\u5316\u7b97\u6cd5\u5305\u62ec\u68af\u5ea6\u4e0b\u964d\u3001\u725b\u987f\u6cd5\u3001\u62df\u725b\u987f\u6cd5\u3001Adam \u7b49\u3002<\/p>\n\n\n\n<p>9. \u5b66\u4e60\u63a8\u7406\u4e0e\u89e3\u91ca\uff1a\u673a\u5668\u5b66\u4e60\u6a21\u578b\u901a\u5e38\u5177\u6709\u8f83\u9ad8\u7684\u590d\u6742\u5ea6\uff0c\u56e0\u6b64\u89e3\u91ca\u6a21\u578b\u5982\u4f55\u505a\u51fa\u51b3\u7b56\u81f3\u5173\u91cd\u8981\u3002\u5b66\u4e60\u63a8\u7406\u65e8\u5728\u63d0\u9ad8\u6a21\u578b\u7684\u53ef\u89e3\u91ca\u6027\uff0c\u4ee5\u4fbf\u7528\u6237\u66f4\u597d\u5730\u7406\u89e3\u6a21\u578b\u7684\u51b3\u7b56\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>10. \u8de8\u5b66\u79d1\u7814\u7a76\uff1a\u673a\u5668\u5b66\u4e60\u4e0e\u5176\u4ed6\u5b66\u79d1\u7684\u4ea4\u53c9\u7814\u7a76\uff0c\u5982\u8ba1\u7b97\u673a\u89c6\u89c9\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u751f\u7269\u4fe1\u606f\u5b66\u3001\u91d1\u878d\u7ecf\u6d4e\u5b66\u7b49\uff0c\u4e3a\u89e3\u51b3\u5404\u7c7b\u79d1\u5b66\u95ee\u9898\u63d0\u4f9b\u4e86\u9ad8\u6548\u3001\u7cbe\u786e\u7684\u65b9\u6cd5\u548c\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e9b\u7814\u7a76\u9886\u57df\u76f8\u4e92\u5173\u8054\uff0c\u5171\u540c\u63a8\u52a8\u4e86\u673a\u5668\u5b66\u4e60\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\u3002\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u5347\u548c\u5927\u6570\u636e\u7684\u666e\u53ca\uff0c\u673a\u5668\u5b66\u4e60\u5728\u8bb8\u591a\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u6210\u679c\uff0c\u5e76\u5728\u672a\u6765\u5c06\u7ee7\u7eed\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n\n\n\n<p>MNIST \u6570\u636e\u96c6&nbsp;<\/p>\n\n\n\n<p>&nbsp;<strong>MNIST\uff08Modified National Institute of Standards and Technology database\uff09<\/strong>\u6570\u636e\u96c6\u662f\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684\u624b\u5199\u6570\u5b57\u8bc6\u522b\u6570\u636e\u96c6\u3002\u5b83\u7531\u7f8e\u56fd\u56fd\u5bb6\u6807\u51c6\u4e0e\u6280\u672f\u7814\u7a76\u9662\uff08NIST\uff09\u521b\u5efa\uff0c\u7528\u4e8e\u8bad\u7ec3\u548c\u6d4b\u8bd5\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u5728\u56fe\u50cf\u5206\u7c7b\u548c\u8bc6\u522b\u4efb\u52a1\u4e0a\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p>MNIST \u6570\u636e\u96c6\u5305\u542b 60000 \u4e2a\u8bad\u7ec3\u6837\u672c\u548c 10000 \u4e2a\u6d4b\u8bd5\u6837\u672c\u3002\u8bad\u7ec3\u6837\u672c\u5305\u62ec 0-9 \u5341\u4e2a\u6570\u5b57\u7684\u5404\u79cd\u4e66\u5199\u98ce\u683c\uff0c\u800c\u6d4b\u8bd5\u6837\u672c\u5305\u542b\u76f8\u540c\u7684\u6570\u5b57\uff0c\u4f46\u4e66\u5199\u98ce\u683c\u7565\u6709\u4e0d\u540c\u3002\u6bcf\u4e2a\u6837\u672c\u90fd\u662f\u4e00\u4e2a 28&#215;28 \u50cf\u7d20\u7684\u7070\u5ea6\u56fe\u50cf\u3002<\/p>\n\n\n\n<p><strong>MNIST \u6570\u636e\u96c6\u88ab\u5e7f\u6cdb\u7528\u4e8e\u5404\u79cd\u673a\u5668\u5b66\u4e60\u5b9e\u9a8c<\/strong>\uff0c\u4f8b\u5982\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u548c\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08RNN\uff09\u7b49\u3002\u5b83\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u57fa\u51c6\u6570\u636e\u96c6\uff0c\u56e0\u4e3a\u5176\u6613\u4e8e\u5904\u7406\u4e14\u5177\u6709\u8f83\u597d\u7684\u5e73\u8861\u6027\u3002\u901a\u8fc7\u5728 MNIST \u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u548c\u8bc4\u4f30\u6a21\u578b\uff0c\u7814\u7a76\u4eba\u5458\u53ef\u4ee5\u4e86\u89e3\u4e0d\u540c\u7b97\u6cd5\u548c\u6a21\u578b\u5728\u56fe\u50cf\u8bc6\u522b\u4efb\u52a1\u4e0a\u7684\u6027\u80fd\uff0c\u5e76\u4e3a\u8fdb\u4e00\u6b65\u7684\u7814\u7a76\u63d0\u4f9b\u57fa\u7840\u3002<\/p>\n\n\n\n<p>MNIST \u6570\u636e\u96c6\u53ef\u4ee5\u5728\u7ebf\u83b7\u53d6\uff0c\u6709\u8bb8\u591a\u73b0\u6210\u7684\u6570\u636e\u96c6\u5904\u7406\u548c\u6807\u6ce8\u5de5\u5177\uff0c\u65b9\u4fbf\u7814\u7a76\u4eba\u5458\u5f00\u5c55\u76f8\u5173\u7814\u7a76\u5de5\u4f5c\u3002\u603b\u7684\u6765\u8bf4\uff0cMNIST \u6570\u636e\u96c6\u5728\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u9886\u57df\u5177\u6709\u91cd\u8981\u7684\u5e94\u7528\u4ef7\u503c\u3002<\/p>\n\n\n\n<p>1 &#8211; \u7b80\u4ecb<\/p>\n\n\n\n<p>&nbsp;\u7565<\/p>\n\n\n\n<p>2 &#8211; \u57fa\u672c\u6a21\u578b<\/p>\n\n\n\n<p><strong>\u7ebf\u6027\u56de\u5f52&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u7ebf\u6027\u56de\u5f52\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p><strong>1. \u5bfc\u5165\u6240\u9700\u5e93&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>2. \u51c6\u5907\u6570\u636e\u96c6&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>3. \u6784\u5efa\u7ebf\u6027\u56de\u5f52\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>4. \u7f16\u8bd1\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>5. \u8bad\u7ec3\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>6. \u8bc4\u4f30\u6a21\u578b<\/strong><\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<p><strong>&#8220;`python&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>import tensorflow as tf&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.datasets import train_test_split&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.models import Sequential&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.layers import Dense&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.optimizers import SGD&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.metrics import MeanSquaredError<\/p>\n\n\n\n<p><strong># \u51c6\u5907\u6570\u636e\u96c6&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong># \u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6570\u636e\u96c6\uff0c\u4f60\u53ef\u4ee5\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u96c6&nbsp;<\/strong>&nbsp;<\/p>\n\n\n\n<p>X = np.random.rand(100, 1)&nbsp;&nbsp;<\/p>\n\n\n\n<p>y = 0.1 * X + 0.3<\/p>\n\n\n\n<p><strong># \u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/p>\n\n\n\n<p><strong># \u6784\u5efa\u7ebf\u6027\u56de\u5f52\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model = Sequential()&nbsp;&nbsp;<\/p>\n\n\n\n<p>model.add(Dense(units=1, input_shape=(1,)))<\/p>\n\n\n\n<p><strong># \u7f16\u8bd1\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model.compile(loss=&#8217;mean_squared_error&#8217;, optimizer=SGD(0.1), metrics=[&#8216;accuracy&#8217;])<\/p>\n\n\n\n<p><strong># \u8bad\u7ec3\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model.fit(X_train, y_train, epochs=100, batch_size=10)<\/p>\n\n\n\n<p><strong># \u8bc4\u4f30\u6a21\u578b&nbsp;<\/strong>&nbsp;<\/p>\n\n\n\n<p>loss, accuracy = model.evaluate(X_test, y_test)&nbsp;&nbsp;<\/p>\n\n\n\n<p>print(&#8220;Test loss: &#8220;, loss)&nbsp;&nbsp;<\/p>\n\n\n\n<p>print(&#8220;Test accuracy: &#8220;, accuracy)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&#8220;`<\/p>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 TensorFlow \u7684`Sequential`\u6a21\u578b\uff0c\u5e76\u6dfb\u52a0\u4e86\u4e00\u4e2a\u7ebf\u6027\u5c42\uff08`Dense`\uff09\u4f5c\u4e3a\u8f93\u5165\u5c42\u3002\u63a5\u7740\uff0c\u6211\u4eec\u4f7f\u7528`train_test_split`\u51fd\u6570\u5c06\u6570\u636e\u96c6\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002\u7136\u540e\u7f16\u8bd1\u6a21\u578b\uff0c\u6307\u5b9a\u635f\u5931\u51fd\u6570\u4e3a\u5747\u65b9\u8bef\u5dee\uff08`mean_squared_error`\uff09\uff0c\u4f18\u5316\u5668\u4e3a\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08`SGD`\uff09\uff0c\u5e76\u8bad\u7ec3\u6a21\u578b\u3002\u6700\u540e\uff0c\u6211\u4eec\u8bc4\u4f30\u6a21\u578b\u5728\u6d4b\u8bd5\u96c6\u4e0a\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e2a\u793a\u4f8b\u4ec5\u7528\u4e8e\u8bf4\u660e\u5982\u4f55\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u7ebf\u6027\u56de\u5f52\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574\u6570\u636e\u9884\u5904\u7406\u3001\u6a21\u578b\u7ed3\u6784\u548c\u8bad\u7ec3\u53c2\u6570\u7b49\u3002<\/p>\n\n\n\n<p><strong>\u903b\u8f91\u56de\u5f52<\/strong>&nbsp;<\/p>\n\n\n\n<p>&nbsp;\u903b\u8f91\u56de\u5f52\uff08Logistic Regression\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u5206\u7c7b\u95ee\u9898\u7684\u7ebf\u6027\u6a21\u578b\u3002\u5b83\u901a\u8fc7\u5bf9\u8f93\u5165\u7279\u5f81\u8fdb\u884c\u52a0\u6743\u6c42\u548c\uff0c\u7136\u540e\u8ba1\u7b97\u8f93\u51fa\u6982\u7387\uff0c\u4ece\u800c\u5224\u65ad\u6bcf\u4e2a\u6837\u672c\u5c5e\u4e8e\u6b63\u7c7b\u7684\u6982\u7387\u3002\u903b\u8f91\u56de\u5f52\u6a21\u578b\u901a\u5e38\u7528\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff0c\u4f8b\u5982\u91d1\u878d\u98ce\u9669\u8bc4\u4f30\u3001\u5783\u573e\u90ae\u4ef6\u8fc7\u6ee4\u548c\u751f\u7269\u4fe1\u606f\u5b66\u7b49\u9886\u57df\u3002<\/p>\n\n\n\n<p>\u903b\u8f91\u56de\u5f52\u7684\u4e3b\u8981\u4f18\u70b9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1. \u6613\u4e8e\u7406\u89e3\u548c\u5b9e\u73b0\uff1a\u903b\u8f91\u56de\u5f52\u6a21\u578b\u7ed3\u6784\u7b80\u5355\uff0c\u5bb9\u6613\u89e3\u91ca\uff0c\u4fbf\u4e8e\u7406\u89e3\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>2. \u9002\u7528\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff1a\u903b\u8f91\u56de\u5f52\u5728\u5904\u7406\u4e8c\u5206\u7c7b\u95ee\u9898\u4e0a\u8868\u73b0\u51fa\u8f83\u9ad8\u7684\u51c6\u786e\u6027\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>3. \u80fd\u8bc6\u522b\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\uff1a\u901a\u8fc7\u8c03\u6574\u7279\u5f81\u6743\u91cd\uff0c\u903b\u8f91\u56de\u5f52\u53ef\u4ee5\u8bc6\u522b\u51fa\u7279\u5f81\u4e4b\u95f4\u7684\u76f8\u5bf9\u91cd\u8981\u6027\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0c\u903b\u8f91\u56de\u5f52\u4e5f\u5b58\u5728\u4e00\u4e9b\u5c40\u9650\u6027\uff1a<\/p>\n\n\n\n<p>1. \u8ba1\u7b97\u590d\u6742\u5ea6\uff1a\u5bf9\u4e8e\u9ad8\u7ef4\u6570\u636e\uff0c\u903b\u8f91\u56de\u5f52\u7684\u8ba1\u7b97\u590d\u6742\u5ea6\u8f83\u9ad8\uff0c\u56e0\u4e3a\u9700\u8981\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u6743\u91cd\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>2. \u5bb9\u6613\u8fc7\u62df\u5408\uff1a\u7531\u4e8e\u903b\u8f91\u56de\u5f52\u6a21\u578b\u7684\u7b80\u5355\u6027\uff0c\u5b83\u5bb9\u6613\u8fc7\u62df\u5408\u6570\u636e\uff0c\u5c24\u5176\u662f\u5728\u6837\u672c\u6570\u91cf\u8f83\u5c11\u7684\u60c5\u51b5\u4e0b\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>3. \u7279\u5f81\u6570\u91cf\u9650\u5236\uff1a\u5f53\u7279\u5f81\u6570\u91cf\u8f83\u5927\u65f6\uff0c\u903b\u8f91\u56de\u5f52\u7684\u8ba1\u7b97\u6210\u672c\u548c\u5b58\u50a8\u6210\u672c\u4f1a\u663e\u8457\u589e\u52a0\uff0c\u53ef\u80fd\u5bfc\u81f4\u6a21\u578b\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n\n\n\n<p>\u5c3d\u7ba1\u5982\u6b64\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u903b\u8f91\u56de\u5f52\u4ecd\u7136\u662f\u4e00\u4e2a\u6709\u6548\u7684\u5206\u7c7b\u65b9\u6cd5\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u95ee\u9898\u7279\u70b9\u548c\u6570\u636e\u60c5\u51b5\u6765\u9009\u62e9\u5408\u9002\u7684\u6a21\u578b\u3002<\/p>\n\n\n\n<p><strong>\u4ee5\u4e0b\u662f\u903b\u8f91\u56de\u5f52\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/strong><\/p>\n\n\n\n<p>1. \u521d\u59cb\u5316\u53c2\u6570\uff1a\u8bbe\u7f6e\u521d\u59cb\u6743\u91cd\u5411\u91cf\uff08\u6743\u91cd\uff09\u548c\u504f\u7f6e\u9879\uff08\u504f\u7f6e\uff09\u4e3a\u96f6\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>2. \u6b63\u5411\u4f20\u64ad\uff1a\u5c06\u8f93\u5165\u7279\u5f81\u4e58\u4ee5\u6743\u91cd\uff0c\u7136\u540e\u6c42\u548c\uff0c\u5f97\u5230\u51c0\u8f93\u5165\u3002\u5c06\u51c0\u8f93\u5165\u4f20\u9012\u7ed9\u6fc0\u6d3b\u51fd\u6570\uff0c\u5f97\u5230\u8f93\u51fa\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>3. \u8ba1\u7b97\u635f\u5931\uff1a\u6839\u636e\u5b9e\u9645\u6807\u7b7e\u548c\u6a21\u578b\u8f93\u51fa\uff0c\u8ba1\u7b97\u635f\u5931\u51fd\u6570\uff08\u5982\u4e8c\u5143\u4ea4\u53c9\u71b5\u635f\u5931\uff09\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>4. \u53cd\u5411\u4f20\u64ad\uff1a\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u5173\u4e8e\u6743\u91cd\u548c\u504f\u7f6e\u7684\u68af\u5ea6\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>5. \u66f4\u65b0\u6743\u91cd\u548c\u504f\u7f6e\uff1a\u4f7f\u7528\u68af\u5ea6\u4e0b\u964d\u7b49\u4f18\u5316\u7b97\u6cd5\uff0c\u6839\u636e\u5b66\u4e60\u7387\u66f4\u65b0\u6743\u91cd\u548c\u504f\u7f6e\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002&nbsp;&nbsp;<\/p>\n\n\n\n<p>6. \u91cd\u590d\u6b65\u9aa4 2-5\uff0c\u76f4\u5230\u6a21\u578b\u6536\u655b\u6216\u8fbe\u5230\u9884\u8bbe\u7684\u8fed\u4ee3\u6b21\u6570\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u8c03\u6574\u6743\u91cd\u548c\u504f\u7f6e\uff0c\u903b\u8f91\u56de\u5f52\u6a21\u578b\u53ef\u4ee5\u5b66\u4e60\u5230\u8f93\u5165\u7279\u5f81\u548c\u8f93\u51fa\u6807\u7b7e\u4e4b\u95f4\u7684\u6620\u5c04\u5173\u7cfb\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ea4\u53c9\u9a8c\u8bc1\u7b49\u65b9\u6cd5\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\uff0c\u4ee5\u786e\u4fdd\u6a21\u578b\u5728\u672a\u89c1\u8fc7\u7684\u6570\u636e\u4e0a\u5177\u6709\u826f\u597d\u7684\u6cdb\u5316\u80fd\u529b\u3002<\/p>\n\n\n\n<p><strong>Word2Vec\uff08\u8bcd\u5d4c\u5165\uff09&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;Word2Vec\uff08\u8bcd\u5d4c\u5165\uff09\u662f\u4e00\u79cd\u5c06\u8bcd\u8bed\u8868\u793a\u4e3a\u5b9e\u6570\u503c\u5411\u91cf\u7684\u65b9\u6cd5\u3002\u5b83\u901a\u8fc7\u5c06\u8bcd\u8bed\u6620\u5c04\u5230\u5411\u91cf\u7a7a\u95f4\uff0c\u6355\u6349\u8bcd\u8bed\u4e4b\u95f4\u7684\u8bed\u4e49\u3001\u4e0a\u4e0b\u6587\u548c\u53e5\u6cd5\u5173\u7cfb\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u6587\u672c\u6570\u636e\u7684\u964d\u7ef4\u548c\u7279\u5f81\u63d0\u53d6\u3002Word2Vec \u6280\u672f\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u9886\u57df\u5177\u6709\u91cd\u8981\u4f5c\u7528\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u8bcd\u6c47\u76f8\u4f3c\u6027\u8ba1\u7b97\u3001\u6587\u672c\u5206\u7c7b\u3001\u60c5\u611f\u5206\u6790\u7b49\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>Word2Vec \u4e3b\u8981\u6709\u4e24\u79cd\u751f\u6210\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>1. \u57fa\u4e8e\u9759\u6001\u8bcd\u6c47\u8868\u7684\u65b9\u6cd5\uff1a\u8fd9\u79cd\u65b9\u6cd5\u5c06\u8bcd\u8bed\u6620\u5c04\u5230\u56fa\u5b9a\u5927\u5c0f\u7684\u5411\u91cf\u7a7a\u95f4\uff0c\u6bcf\u4e2a\u8bcd\u8bed\u90fd\u6709\u4e00\u4e2a\u5bf9\u5e94\u7684\u5411\u91cf\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u6613\u5b9e\u73b0\uff0c\u4f46\u65e0\u6cd5\u6355\u6349\u8bcd\u8bed\u4e4b\u95f4\u7684\u52a8\u6001\u5173\u7cfb\u3002<\/p>\n\n\n\n<p>2. \u57fa\u4e8e\u4e0a\u4e0b\u6587\u7684\u65b9\u6cd5\uff1a\u8fd9\u79cd\u65b9\u6cd5\u901a\u8fc7\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\uff0c\u6839\u636e\u8bcd\u8bed\u5728\u6587\u672c\u4e2d\u7684\u4e0a\u4e0b\u6587\u5173\u7cfb\u5b66\u4e60\u8bcd\u6c47\u5411\u91cf\u3002\u8fd9\u79cd\u65b9\u6cd5\u80fd\u591f\u6355\u6349\u8bcd\u8bed\u7684\u8bed\u4e49\u548c\u53e5\u6cd5\u4fe1\u606f\uff0c\u4f46\u8ba1\u7b97\u590d\u6742\u5ea6\u8f83\u9ad8\u3002<\/p>\n\n\n\n<p>Word2Vec \u6280\u672f\u7684\u521b\u59cb\u4eba\u662f Tomasz Kukuczka \u548c James Lewis\uff0c\u4ed6\u4eec\u4e8e 2013 \u5e74\u63d0\u51fa\u4e86 Word2Vec \u6a21\u578b\u3002\u81ea\u90a3\u65f6\u4ee5\u6765\uff0cWord2Vec \u6210\u4e3a NLP \u9886\u57df\u7684\u91cd\u8981\u7814\u7a76\u70ed\u70b9\uff0c\u63a8\u52a8\u4e86\u8bcd\u6c47\u8868\u793a\u65b9\u6cd5\u7684\u53d1\u5c55\u3002<\/p>\n\n\n\n<p><strong>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 Word2Vec \u5e94\u7528\uff1a<\/strong><\/p>\n\n\n\n<p>1. \u8bcd\u6c47\u76f8\u4f3c\u6027\u8ba1\u7b97\uff1a\u901a\u8fc7\u8ba1\u7b97\u8bcd\u8bed\u5411\u91cf\u4e4b\u95f4\u7684\u4f59\u5f26\u76f8\u4f3c\u5ea6\uff0c\u53ef\u4ee5\u8bc4\u4f30\u8bcd\u6c47\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002<\/p>\n\n\n\n<p>2. \u6587\u672c\u5206\u7c7b\uff1a\u5c06\u6587\u672c\u6570\u636e\u8f6c\u6362\u4e3a\u8bcd\u6c47\u5411\u91cf\u77e9\u9635\uff0c\u7136\u540e\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff08\u5982\u652f\u6301\u5411\u91cf\u673a\u3001\u795e\u7ecf\u7f51\u7edc\u7b49\uff09\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n\n\n\n<p>3. \u60c5\u611f\u5206\u6790\uff1a\u5c06\u6587\u672c\u4e2d\u7684\u8bcd\u8bed\u8f6c\u6362\u4e3a\u5411\u91cf\uff0c\u7136\u540e\u901a\u8fc7\u8ba1\u7b97\u60c5\u611f\u5f97\u5206\u6765\u5206\u6790\u6587\u672c\u7684\u60c5\u611f\u503e\u5411\u3002<\/p>\n\n\n\n<p>4. \u8bcd\u4e49\u6d88\u6b67\uff1a\u901a\u8fc7\u6bd4\u8f83\u8bcd\u8bed\u5411\u91cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\uff0c\u6d88\u9664\u540c\u4e49\u8bcd\u3001\u8fd1\u4e49\u8bcd\u7b49\u5f15\u8d77\u7684\u6b67\u4e49\u3002<\/p>\n\n\n\n<p>5. \u673a\u5668\u7ffb\u8bd1\uff1a\u5c06\u6e90\u8bed\u8a00\u7684\u8bcd\u6c47\u5411\u91cf\u8f6c\u6362\u4e3a\u76ee\u6807\u8bed\u8a00\u7684\u8bcd\u6c47\u5411\u91cf\uff0c\u4ece\u800c\u5b9e\u73b0\u673a\u5668\u7ffb\u8bd1\u3002<\/p>\n\n\n\n<p>\u603b\u4e4b\uff0cWord2Vec \u4f5c\u4e3a\u4e00\u79cd\u6709\u6548\u7684\u8bcd\u5d4c\u5165\u65b9\u6cd5\uff0c\u5728 NLP \u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u4ef7\u503c\u3002\u5b83\u4e3a\u540e\u7eed\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u8bcd\u6c47\u8868\u793a\u4fe1\u606f\uff0c\u63a8\u52a8\u4e86 NLP \u6280\u672f\u7684\u53d1\u5c55\u3002<\/p>\n\n\n\n<p><strong>GBDT\uff08\u68af\u5ea6\u63d0\u5347\u51b3\u7b56\u6811\uff09<\/strong>&nbsp;<\/p>\n\n\n\n<p>&nbsp;GBDT\uff08Gradient Boosting Decision Tree\uff0c\u68af\u5ea6\u63d0\u5347\u51b3\u7b56\u6811\uff09\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u76d1\u7763\u5b66\u4e60\u7b97\u6cd5\uff0c\u4e3b\u8981\u7528\u4e8e\u56de\u5f52\u548c\u5206\u7c7b\u4efb\u52a1\u3002\u5b83\u901a\u8fc7\u8fed\u4ee3\u5730\u8bad\u7ec3\u7b80\u5355\u7684\u57fa\u5b66\u4e60\u5668\uff08\u5982\u51b3\u7b56\u6811\uff09\uff0c\u5e76\u7ed3\u5408\u8fd9\u4e9b\u57fa\u5b66\u4e60\u5668\u7684\u8f93\u51fa\uff0c\u4ee5\u964d\u4f4e\u635f\u5931\u51fd\u6570\u7684\u68af\u5ea6\uff0c\u4ece\u800c\u63d0\u9ad8\u6a21\u578b\u7684\u9884\u6d4b\u6027\u80fd\u3002<\/p>\n\n\n\n<p>GBDT \u4e3b\u8981\u7531\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n\n\n\n<p>1. \u51b3\u7b56\u6811\uff1aGBDT \u4f7f\u7528 CART\uff08\u5206\u7c7b\u4e0e\u56de\u5f52\u6811\uff09\u4f5c\u4e3a\u57fa\u5b66\u4e60\u5668\u3002CART \u662f\u4e00\u79cd\u4e8c\u53c9\u6811\u7ed3\u6784\uff0c\u6bcf\u4e2a\u5185\u90e8\u8282\u70b9\u8868\u793a\u4e00\u4e2a\u7279\u5f81\uff0c\u6bcf\u4e2a\u5206\u652f\u8868\u793a\u4e00\u4e2a\u51b3\u7b56\u89c4\u5219\u3002\u53f6\u5b50\u8282\u70b9\u5219\u8868\u793a\u7c7b\u522b\u6807\u7b7e\u6216\u6570\u503c\u9884\u6d4b\u3002<\/p>\n\n\n\n<p>2. \u68af\u5ea6\u63d0\u5347\uff1aGBDT \u901a\u8fc7\u68af\u5ea6\u63d0\u5347\u7b56\u7565\u6765\u4f18\u5316\u57fa\u5b66\u4e60\u5668\u7684\u6027\u80fd\u3002\u68af\u5ea6\u63d0\u5347\u662f\u6307\u5728\u6bcf\u6b21\u8fed\u4ee3\u4e2d\uff0c\u6839\u636e\u5f53\u524d\u6a21\u578b\u7684\u9884\u6d4b\u8bef\u5dee\u8c03\u6574\u6837\u672c\u6743\u91cd\uff0c\u4f7f\u5f97\u540e\u7eed\u7684\u57fa\u5b66\u4e60\u5668\u66f4\u52a0\u5173\u6ce8\u9519\u8bef\u7684\u6837\u672c\u3002\u6743\u91cd\u8c03\u6574\u540e\uff0c\u57fa\u5b66\u4e60\u5668\u7684\u8bad\u7ec3\u8fc7\u7a0b\u5c06\u66f4\u52a0\u5173\u6ce8\u63d0\u9ad8\u9884\u6d4b\u6027\u80fd\u3002<\/p>\n\n\n\n<p>3. \u635f\u5931\u51fd\u6570\uff1aGBDT \u4e2d\u7684\u635f\u5931\u51fd\u6570\u53ef\u4ee5\u662f\u5747\u65b9\u8bef\u5dee\uff08MSE\uff09\u6216\u4ea4\u53c9\u71b5\uff08\u5bf9\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff09\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u4efb\u52a1\u7c7b\u578b\u3002\u635f\u5931\u51fd\u6570\u7528\u4e8e\u8bc4\u4f30\u6a21\u578b\u7684\u9884\u6d4b\u6027\u80fd\uff0c\u5e76\u6307\u5bfc\u68af\u5ea6\u63d0\u5347\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>4. \u7279\u5f81\u91cd\u8981\u6027\uff1aGBDT \u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u7279\u5f81\u7684\u76f8\u5bf9\u91cd\u8981\u6027\u6765\u5e2e\u52a9\u5206\u6790\u7279\u5f81\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u91cd\u8981\u6027\u8f83\u9ad8\u7684\u7279\u5f81\u5bf9\u57fa\u5b66\u4e60\u5668\u7684\u9884\u6d4b\u8d21\u732e\u8f83\u5927\uff0c\u56e0\u6b64\u5728\u6a21\u578b\u6784\u5efa\u8fc7\u7a0b\u4e2d\u5e94\u7ed9\u4e88\u5173\u6ce8\u3002<\/p>\n\n\n\n<p><strong>GBDT \u7684\u4f18\u70b9\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<p>1. \u5f3a\u5927\u7684\u6cdb\u5316\u80fd\u529b\uff1aGBDT \u5728\u56de\u5f52\u548c\u5206\u7c7b\u4efb\u52a1\u4e0a\u90fd\u8868\u73b0\u51fa\u8f83\u597d\u7684\u6027\u80fd\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u9ad8\u7ef4\u5ea6\u6570\u636e\u548c\u566a\u58f0\u6570\u636e\u65f6\u3002<\/p>\n\n\n\n<p>2. \u6613\u4e8e\u7406\u89e3\u548c\u5b9e\u73b0\uff1aGBDT \u7b97\u6cd5\u76f8\u5bf9\u7b80\u5355\uff0c\u5bb9\u6613\u89e3\u91ca\u548c\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>3. \u7279\u5f81\u91cd\u8981\u6027\u5206\u6790\uff1aGBDT \u53ef\u4ee5\u63d0\u4f9b\u7279\u5f81\u91cd\u8981\u6027\u6392\u540d\uff0c\u6709\u52a9\u4e8e\u540e\u7eed\u7279\u5f81\u9009\u62e9\u548c\u6a21\u578b\u4f18\u5316\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0cGBDT \u4e5f\u5b58\u5728\u4e00\u4e9b\u5c40\u9650\u6027\uff1a<\/p>\n\n\n\n<p>1. \u8ba1\u7b97\u6210\u672c\u9ad8\uff1aGBDT \u7684\u8bad\u7ec3\u8fc7\u7a0b\u6d89\u53ca\u5927\u91cf\u77e9\u9635\u8fd0\u7b97\u548c\u9012\u5f52\u8ba1\u7b97\uff0c\u8ba1\u7b97\u6210\u672c\u8f83\u9ad8\u3002<\/p>\n\n\n\n<p>2. \u8fc7\u62df\u5408\u98ce\u9669\uff1aGBDT \u6709\u53ef\u80fd\u8fc7\u62df\u5408\u8bad\u7ec3\u6570\u636e\uff0c\u5bfc\u81f4\u5728\u65b0\u6570\u636e\u4e0a\u8868\u73b0\u4e0d\u4f73\u3002\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u5316\u7b49\u6280\u672f\u6765\u964d\u4f4e\u8fc7\u62df\u5408\u98ce\u9669\u3002<\/p>\n\n\n\n<p>3. \u65e0\u6cd5\u5904\u7406\u7f3a\u5931\u503c\uff1aGBDT \u96be\u4ee5\u5904\u7406\u7f3a\u5931\u503c\uff0c\u53ef\u80fd\u5bfc\u81f4\u6a21\u578b\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n\n\n\n<p>\u603b\u4e4b\uff0cGBDT \u662f\u4e00\u79cd\u5177\u6709\u5e7f\u6cdb\u5e94\u7528\u4ef7\u503c\u7684\u76d1\u7763\u5b66\u4e60\u7b97\u6cd5\u3002\u901a\u8fc7\u68af\u5ea6\u63d0\u5347\u548c\u51b3\u7b56\u6811\u76f8\u7ed3\u5408\uff0cGBDT \u80fd\u591f\u5728\u56de\u5f52\u548c\u5206\u7c7b\u4efb\u52a1\u4e2d\u53d6\u5f97\u826f\u597d\u6027\u80fd\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u4efb\u52a1\u7279\u70b9\u548c\u6570\u636e\u60c5\u51b5\u8c03\u6574\u6a21\u578b\u53c2\u6570\u548c\u7b56\u7565\uff0c\u4ee5\u5145\u5206\u53d1\u6325 GBDT \u7684\u6f5c\u529b\u3002<\/p>\n\n\n\n<p><strong>3 &#8211; \u795e\u7ecf\u7f51\u7edc<\/strong><\/p>\n\n\n\n<p><strong>\u7b80\u5355\u795e\u7ecf\u7f51\u7edc&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u795e\u7ecf\u7f51\u7edc\u6848\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p>1. \u5bfc\u5165\u6240\u9700\u5e93&nbsp;&nbsp;<\/p>\n\n\n\n<p>2. \u51c6\u5907\u6570\u636e\u96c6&nbsp;&nbsp;<\/p>\n\n\n\n<p>3. \u6784\u5efa\u795e\u7ecf\u7f51\u7edc\u6a21\u578b&nbsp;&nbsp;<\/p>\n\n\n\n<p>4. \u7f16\u8bd1\u6a21\u578b&nbsp;&nbsp;<\/p>\n\n\n\n<p>5. \u8bad\u7ec3\u6a21\u578b&nbsp;&nbsp;<\/p>\n\n\n\n<p>6. \u8bc4\u4f30\u6a21\u578b<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u795e\u7ecf\u7f51\u7edc\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<p>&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>import tensorflow as tf&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.datasets import mnist&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.models import Sequential&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.layers import Dense&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.optimizers import SGD&nbsp;&nbsp;<\/p>\n\n\n\n<p>from tensorflow.keras.metrics import MeanSquaredError<\/p>\n\n\n\n<p><strong># 1. \u5bfc\u5165\u6240\u9700\u5e93&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>import tensorflow as tf<\/p>\n\n\n\n<p><strong># 2. \u51c6\u5907\u6570\u636e\u96c6&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>(x_train, y_train), (x_test, y_test) = mnist.load_data()&nbsp;&nbsp;<\/p>\n\n\n\n<p>x_train, x_test = x_train \/ 255.0, x_test \/ 255.0<\/p>\n\n\n\n<p><strong># 3. \u6784\u5efa\u795e\u7ecf\u7f51\u7edc\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model = Sequential()&nbsp;&nbsp;<\/p>\n\n\n\n<p>model.add(Dense(128, activation=&#8217;relu&#8217;, input_shape=(784,)))&nbsp;&nbsp;<\/p>\n\n\n\n<p>model.add(Dense(128, activation=&#8217;relu&#8217;))&nbsp;&nbsp;<\/p>\n\n\n\n<p>model.add(Dense(10, activation=&#8217;softmax&#8217;))<\/p>\n\n\n\n<p><strong># 4. \u7f16\u8bd1\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model.compile(loss=&#8217;sparse_categorical_crossentropy&#8217;, optimizer=SGD(0.01), metrics=[&#8216;accuracy&#8217;])<\/p>\n\n\n\n<p><strong># 5. \u8bad\u7ec3\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>model.fit(x_train, y_train, epochs=10, validation_data=(x_test, y_test))<\/p>\n\n\n\n<p><strong># 6. \u8bc4\u4f30\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p>test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)&nbsp;&nbsp;<\/p>\n\n\n\n<p>print(&#8216;Test accuracy:&#8217;, test_acc)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&#8220;`<\/p>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 TensorFlow \u7684`Sequential`\u6a21\u578b\uff0c\u5e76\u6dfb\u52a0\u4e86\u4e09\u4e2a\u9690\u85cf\u5c42\uff0c\u6bcf\u4e2a\u9690\u85cf\u5c42\u6709 128 \u4e2a\u795e\u7ecf\u5143\u3002\u8f93\u51fa\u5c42\u4f7f\u7528 10 \u4e2a\u795e\u7ecf\u5143\uff0c\u6fc0\u6d3b\u51fd\u6570\u4e3a softmax\uff0c\u7528\u4e8e\u5b9e\u73b0\u591a\u5206\u7c7b\u3002\u63a5\u7740\uff0c\u6211\u4eec\u7f16\u8bd1\u6a21\u578b\uff0c\u6307\u5b9a\u635f\u5931\u51fd\u6570\u4e3a\u4ea4\u53c9\u71b5\u635f\u5931\uff08`sparse_categorical_crossentropy`\uff09\uff0c\u4f18\u5316\u5668\u4e3a\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08`SGD`\uff09\uff0c\u5e76\u8bad\u7ec3\u6a21\u578b\u3002\u6700\u540e\uff0c\u6211\u4eec\u8bc4\u4f30\u6a21\u578b\u5728\u6d4b\u8bd5\u96c6\u4e0a\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e2a\u793a\u4f8b\u4ec5\u7528\u4e8e\u8bf4\u660e\u5982\u4f55\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u795e\u7ecf\u7f51\u7edc\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574\u6570\u636e\u9884\u5904\u7406\u3001\u6a21\u578b\u7ed3\u6784\u548c\u8bad\u7ec3\u53c2\u6570\u7b49\u3002<\/p>\n\n\n\n<p><strong>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc&nbsp;<\/strong><\/p>\n\n\n\n<p>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08Convolutional Neural Networks\uff0c\u7b80\u79f0 CNN\uff09\u662f\u4e00\u7c7b\u5305\u542b\u5377\u79ef\u8ba1\u7b97\u4e14\u5177\u6709\u6df1\u5ea6\u7ed3\u6784\u7684\u524d\u9988\u795e\u7ecf\u7f51\u7edc\uff08Feedforward Neural Networks\uff09\u3002\u5b83\u662f\u6df1\u5ea6\u5b66\u4e60\uff08Deep Learning\uff09\u7684\u4ee3\u8868\u7b97\u6cd5\u4e4b\u4e00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7b49\u9886\u57df\u3002<\/p>\n\n\n\n<p>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. \u5377\u79ef\u5c42\uff1a\u5377\u79ef\u5c42\u662f CNN \u7684\u6838\u5fc3\u90e8\u5206\uff0c\u7528\u4e8e\u5728\u56fe\u50cf\u6216\u5176\u4ed6\u6570\u636e\u4e0a\u6267\u884c\u5377\u79ef\u64cd\u4f5c\u3002\u5377\u79ef\u64cd\u4f5c\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u53d6\u6570\u636e\u7684\u7279\u5f81\uff0c\u4f8b\u5982\u8fb9\u7f18\u3001\u7eb9\u7406\u7b49\u3002\u5377\u79ef\u5c42\u901a\u5e38\u4f7f\u7528\u53ef\u8bad\u7ec3\u7684\u5377\u79ef\u6838\uff08\u4e5f\u79f0\u4e3a\u6ee4\u6ce2\u5668\uff09\u8fdb\u884c\u5377\u79ef\u8ba1\u7b97\u3002<\/p>\n\n\n\n<p>2. \u6c60\u5316\u5c42\uff1a\u6c60\u5316\u5c42\u7528\u4e8e\u51cf\u5c0f\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\uff0c\u4ece\u800c\u964d\u4f4e\u8ba1\u7b97\u590d\u6742\u5ea6\u3002\u5e38\u7528\u7684\u6c60\u5316\u64cd\u4f5c\u6709\u6700\u5927\u503c\u6c60\u5316\u548c\u5e73\u5747\u503c\u6c60\u5316\u3002\u6c60\u5316\u5c42\u53ef\u4ee5\u5e2e\u52a9\u795e\u7ecf\u7f51\u7edc\u6355\u6349\u56fe\u50cf\u4e2d\u7684\u5c40\u90e8\u7279\u5f81\uff0c\u540c\u65f6\u51cf\u5c11\u8ba1\u7b97\u91cf\u3002<\/p>\n\n\n\n<p>3. \u6fc0\u6d3b\u51fd\u6570\uff1a\u6fc0\u6d3b\u51fd\u6570\u7528\u4e8e\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\uff0c\u4f7f\u795e\u7ecf\u7f51\u7edc\u80fd\u591f\u5b66\u4e60\u66f4\u590d\u6742\u7684\u51fd\u6570\u3002\u5e38\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\u6709 sigmoid\u3001ReLU\uff08Rectified Linear Unit\uff09\u7b49\u3002<\/p>\n\n\n\n<p>4. \u7684\u5168\u8fde\u63a5\u5c42\uff1a\u5168\u8fde\u63a5\u5c42\u5c06\u5377\u79ef\u5c42\u548c\u6c60\u5316\u5c42\u8f93\u51fa\u7684\u7279\u5f81\u56fe\u8f6c\u6362\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u7279\u5f81\u5411\u91cf\u3002\u5168\u8fde\u63a5\u5c42\u540e\u901a\u5e38\u8ddf\u968f\u4e00\u4e2a\u6216\u591a\u4e2a\u5168\u6fc0\u6d3b\u51fd\u6570\uff0c\u7528\u4e8e\u5c06\u7279\u5f81\u5411\u91cf\u6620\u5c04\u4e3a\u7c7b\u522b\u6982\u7387\u3002<\/p>\n\n\n\n<p>5. \u635f\u5931\u51fd\u6570\uff1aCNN \u4e2d\u7684\u635f\u5931\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u8861\u91cf\u6a21\u578b\u9884\u6d4b\u4e0e\u5b9e\u9645\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u8ddd\u3002\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\u6709\u4ea4\u53c9\u71b5\u635f\u5931\uff08Cross-Entropy Loss\uff09\u548c\u5747\u65b9\u8bef\u5dee\u635f\u5931\uff08Mean Squared Error Loss\uff09\u7b49\u3002<\/p>\n\n\n\n<p>6. \u53cd\u5411\u4f20\u64ad\uff1a\u53cd\u5411\u4f20\u64ad\u662f\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u6838\u5fc3\u7b97\u6cd5\uff0c\u7528\u4e8e\u8ba1\u7b97\u68af\u5ea6\u4ee5\u66f4\u65b0\u6a21\u578b\u53c2\u6570\u3002CNN \u4e2d\u7684\u53cd\u5411\u4f20\u64ad\u8fc7\u7a0b\u4f1a\u9010\u5c42\u8ba1\u7b97\u68af\u5ea6\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u5377\u79ef\u6838\u3001\u504f\u7f6e\u548c\u5168\u8fde\u63a5\u5c42\u53c2\u6570\u7684\u4f18\u5316\u3002<\/p>\n\n\n\n<p>7. &nbsp;dropout\uff1adropout \u662f\u4e00\u79cd\u6b63\u5219\u5316\u6280\u672f\uff0c\u7528\u4e8e\u9632\u6b62\u8fc7\u62df\u5408\u3002\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0cdropout \u4f1a\u5728\u4e00\u5b9a\u6982\u7387\u4e0b\u4e22\u5f03\u90e8\u5206\u795e\u7ecf\u5143\uff0c\u4ece\u800c\u4f7f\u6a21\u578b\u66f4\u9c81\u68d2\u3001\u6cdb\u5316\u80fd\u529b\u66f4\u5f3a\u3002<\/p>\n\n\n\n<p>\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u5728\u56fe\u50cf\u8bc6\u522b\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6210\u679c\uff0c\u5982\u51c6\u786e\u8bc6\u522b\u624b\u5199\u6570\u5b57\u3001\u68c0\u6d4b\u7269\u4f53\u548c\u8bc6\u522b\u4eba\u8138\u7b49\u3002\u8fd1\u5e74\u6765\uff0c\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u6280\u672f\u7684\u5feb\u901f\u53d1\u5c55\uff0cCNN \u4e5f\u5728\u5176\u4ed6\u9886\u57df\uff08\u5982\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\uff09\u53d6\u5f97\u4e86\u91cd\u8981\u7a81\u7834\u3002<\/p>\n\n\n\n<p><strong>\u9012\u5f52\u795e\u7ecf\u7f51\u7edc&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\uff08Recurrent Neural Networks\uff0c\u7b80\u79f0 RNN\uff09\u662f\u4e00\u7c7b\u5177\u6709\u9012\u5f52\u7ed3\u6784\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u80fd\u591f\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u548c\u5e8f\u5217\u6570\u636e\u65f6\u6355\u6349\u957f\u8ddd\u79bb\u4f9d\u8d56\u5173\u7cfb\u3002RNN \u7684\u6838\u5fc3\u601d\u60f3\u662f\u901a\u8fc7\u9012\u5f52\u7684\u65b9\u5f0f\u5c06\u5f53\u524d\u65f6\u523b\u7684\u8f93\u5165\u4e0e\u4e4b\u524d\u65f6\u523b\u7684\u8f93\u51fa\u76f8\u7ed3\u5408\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u5e8f\u5217\u6570\u636e\u7684\u5efa\u6a21\u3002<\/p>\n\n\n\n<p>\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. \u9012\u5f52\u7ed3\u6784\uff1aRNN \u7684\u4e3b\u8981\u7279\u70b9\u662f\u5176\u9012\u5f52\u7ed3\u6784\uff0c\u5373\u5f53\u524d\u65f6\u523b\u7684\u8f93\u51fa\u4f1a\u4f5c\u4e3a\u4e0b\u4e00\u65f6\u523b\u7684\u8f93\u5165\u3002\u8fd9\u4f7f\u5f97 RNN \u80fd\u591f\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u957f\u8ddd\u79bb\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n\n\n\n<p>2. \u6fc0\u6d3b\u51fd\u6570\uff1aRNN \u4e2d\u7684\u6fc0\u6d3b\u51fd\u6570\u4e0e\u666e\u901a\u795e\u7ecf\u7f51\u7edc\u7c7b\u4f3c\uff0c\u7528\u4e8e\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\u3002\u5e38\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\u6709 sigmoid\u3001ReLU\uff08Rectified Linear Unit\uff09\u7b49\u3002<\/p>\n\n\n\n<p>3. \u5faa\u73af\u8fde\u63a5\uff1aRNN \u901a\u8fc7\u5faa\u73af\u8fde\u63a5\u5b9e\u73b0\u9012\u5f52\u3002\u5faa\u73af\u8fde\u63a5\u662f\u6307\u5c06\u7f51\u7edc\u7684\u8f93\u51fa\u91cd\u65b0\u8f93\u5165\u5230\u7f51\u7edc\u4e2d\uff0c\u5f62\u6210\u4e00\u4e2a\u95ed\u73af\u7ed3\u6784\u3002\u8fd9\u79cd\u8fde\u63a5\u65b9\u5f0f\u4f7f\u5f97 RNN \u80fd\u591f\u4fdd\u7559\u4e4b\u524d\u65f6\u523b\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>4. \u68af\u5ea6\u6d88\u5931\u4e0e\u68af\u5ea6\u7206\u70b8\uff1a\u7531\u4e8e RNN \u4e2d\u7684\u9012\u5f52\u7ed3\u6784\uff0c\u68af\u5ea6\u5728\u53cd\u5411\u4f20\u64ad\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u6d88\u5931\u6216\u7206\u70b8\uff0c\u5bfc\u81f4\u96be\u4ee5\u5b66\u4e60\u957f\u8ddd\u79bb\u4f9d\u8d56\u5173\u7cfb\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cRNN \u901a\u5e38\u91c7\u7528\u4e00\u4e9b\u6280\u5de7\uff0c\u5982\u68af\u5ea6\u88c1\u526a\u3001\u957f\u77ed\u65f6\u8bb0\u5fc6\u7f51\u7edc\uff08LSTM\uff09\u6216\u95e8\u63a7\u5faa\u73af\u5355\u5143\uff08GRU\uff09\u7b49\u3002<\/p>\n\n\n\n<p>5. \u8bad\u7ec3\u4e0e\u4f18\u5316\uff1aRNN \u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u901a\u5e38\u91c7\u7528\u57fa\u4e8e\u68af\u5ea6\u4e0b\u964d\u7684\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08SGD\uff09\u6216 AdaGrad \u7b49\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002<\/p>\n\n\n\n<p>6. \u5e94\u7528\uff1aRNN \u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u7b49\u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4f8b\u5982\uff0cRNN \u53ef\u4ee5\u7528\u4e8e\u5efa\u6a21\u8bed\u8a00\u6a21\u578b\u3001\u673a\u5668\u7ffb\u8bd1\u3001\u60c5\u611f\u5206\u6790\u7b49\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u867d\u7136 RNN \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u5177\u6709\u4f18\u8d8a\u6027\u80fd\uff0c\u4f46\u5b83\u4eec\u4e5f\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\uff0c\u5982\u8ba1\u7b97\u590d\u6742\u5ea6\u9ad8\u3001\u96be\u4ee5\u5e76\u884c\u5904\u7406\u7b49\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u7814\u7a76\u4eba\u5458\u63d0\u51fa\u4e86\u8bb8\u591a\u6539\u8fdb\u7684 RNN \u6a21\u578b\uff0c\u5982 LSTM\u3001GRU \u7b49\u3002\u8fd9\u4e9b\u6539\u8fdb\u7684\u6a21\u578b\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u514b\u670d\u4e86\u539f\u59cb RNN \u7684\u5c40\u9650\u6027\uff0c\u5e76\u5728\u5404\u79cd\u5e94\u7528\u9886\u57df\u53d6\u5f97\u4e86\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08Bidirectional Recurrent Neural Networks\uff0c\u7b80\u79f0 BRNN\uff09\u662f\u4e00\u79cd\u5728\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\uff08RNN\uff09\u57fa\u7840\u4e0a\u6269\u5c55\u800c\u6765\u7684\u7f51\u7edc\u7ed3\u6784\u3002\u4e0e\u4f20\u7edf\u7684\u5355\u5411 RNN \u4e0d\u540c\uff0cBRNN \u80fd\u591f\u5728\u53cc\u5411\u65f6\u95f4\u7ef4\u5ea6\u4e0a\u6355\u6349\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4ece\u800c\u66f4\u597d\u5730\u5b66\u4e60\u8f93\u5165\u5e8f\u5217\u4e2d\u7684\u957f\u8ddd\u79bb\u4f9d\u8d56\u3002<\/p>\n\n\n\n<p>\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. \u53cc\u5411\u7ed3\u6784\uff1aBRNN \u7684\u6838\u5fc3\u7279\u70b9\u662f\u5176\u53cc\u5411\u7ed3\u6784\uff0c\u5373\u540c\u65f6\u8003\u8651\u5e8f\u5217\u7684\u524d\u5411\u548c\u540e\u5411\u4fe1\u606f\u3002\u901a\u8fc7\u53cc\u5411\u8ba1\u7b97\uff0cBRNN \u80fd\u591f\u66f4\u5168\u9762\u5730\u6355\u6349\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u63d0\u9ad8\u6a21\u578b\u7684\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n\n\n\n<p>2. \u4e24\u4e2a\u65b9\u5411\u7684\u8f93\u5165\uff1aBRNN \u63a5\u6536\u4e24\u4e2a\u65b9\u5411\u7684\u8f93\u5165\uff0c\u5206\u522b\u662f\u6b63\u5411\u8f93\u5165\uff08\u4ece\u8d77\u59cb\u65f6\u523b\u5230\u5f53\u524d\u65f6\u523b\uff09\u548c\u53cd\u5411\u8f93\u5165\uff08\u4ece\u5f53\u524d\u65f6\u523b\u5230\u8d77\u59cb\u65f6\u523b\uff09\u3002\u8fd9\u4e24\u4e2a\u65b9\u5411\u7684\u8f93\u5165\u4f1a\u5728\u6bcf\u4e2a\u65f6\u95f4\u6b65\u8fdb\u884c\u878d\u5408\uff0c\u4ee5\u5f62\u6210\u66f4\u4e30\u5bcc\u7684\u7279\u5f81\u8868\u793a\u3002<\/p>\n\n\n\n<p>3. \u9690\u85cf\u5c42\uff1aBRNN \u7684\u9690\u85cf\u5c42\u7ed3\u6784\u4e0e\u5355\u5411 RNN \u7c7b\u4f3c\uff0c\u5305\u542b\u591a\u4e2a\u5c42\u7ea7\u7684\u795e\u7ecf\u5143\u3002\u5728\u6bcf\u4e2a\u65f6\u95f4\u6b65\uff0c\u6b63\u5411\u548c\u53cd\u5411\u9690\u85cf\u5c42\u4f1a\u5206\u522b\u8ba1\u7b97\u51fa\u5bf9\u5e94\u7684\u9690\u85cf\u72b6\u6001\uff0c\u8fd9\u4e9b\u72b6\u6001\u4f1a\u878d\u5408\u540e\u4f5c\u4e3a\u4e0b\u4e00\u5c42\u8f93\u5165\u3002<\/p>\n\n\n\n<p>4. \u6fc0\u6d3b\u51fd\u6570\uff1aBRNN \u4e2d\u7684\u6fc0\u6d3b\u51fd\u6570\u4e0e\u5355\u5411 RNN \u76f8\u540c\uff0c\u7528\u4e8e\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\u3002\u5e38\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\u6709 sigmoid\u3001ReLU\uff08Rectified Linear Unit\uff09\u7b49\u3002<\/p>\n\n\n\n<p>5. \u635f\u5931\u51fd\u6570\uff1aBRNN \u7684\u635f\u5931\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u8861\u91cf\u6a21\u578b\u9884\u6d4b\u4e0e\u5b9e\u9645\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u8ddd\u3002\u4e0e\u5355\u5411 RNN \u7c7b\u4f3c\uff0cBRNN \u4e5f\u53ef\u4ee5\u91c7\u7528\u4ea4\u53c9\u71b5\u635f\u5931\uff08Cross-Entropy Loss\uff09\u6216\u5747\u65b9\u8bef\u5dee\u635f\u5931\uff08Mean Squared Error Loss\uff09\u7b49\u4f5c\u4e3a\u635f\u5931\u51fd\u6570\u3002<\/p>\n\n\n\n<p>6. \u8bad\u7ec3\u4e0e\u4f18\u5316\uff1aBRNN \u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u91c7\u7528\u57fa\u4e8e\u68af\u5ea6\u4e0b\u964d\u7684\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08SGD\uff09\u6216 AdaGrad \u7b49\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002<\/p>\n\n\n\n<p>7. \u5e94\u7528\uff1aBRNN \u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u7b49\u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u524d\u666f\u3002\u4f8b\u5982\uff0c\u5728\u673a\u5668\u7ffb\u8bd1\u4efb\u52a1\u4e2d\uff0cBRNN \u53ef\u4ee5\u540c\u65f6\u6355\u6349\u6e90\u8bed\u8a00\u548c\u76ee\u6807\u8bed\u8a00\u4e4b\u95f4\u7684\u957f\u8ddd\u79bb\u4f9d\u8d56\u5173\u7cfb\uff0c\u63d0\u9ad8\u7ffb\u8bd1\u8d28\u91cf\u3002<\/p>\n\n\n\n<p>\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\u8868\u73b0\u51fa\u4f18\u8d8a\u7684\u6027\u80fd\uff0c\u5982\u673a\u5668\u7ffb\u8bd1\u3001\u8bed\u97f3\u8bc6\u522b\u7b49\u3002\u7136\u800c\uff0cBRNN \u4e5f\u9762\u4e34\u7740\u8ba1\u7b97\u590d\u6742\u5ea6\u9ad8\u3001\u96be\u4ee5\u5e76\u884c\u5904\u7406\u7b49\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u7814\u7a76\u4eba\u5458\u4e00\u76f4\u5728\u63a2\u7d22\u66f4\u9ad8\u6548\u7684\u53cc\u5411\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u53ca\u5176\u53d8\u79cd\uff0c\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\u548c\u6548\u7387\u3002<\/p>\n\n\n\n<p><strong>\u52a8\u6001\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08LSTM\uff09&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u52a8\u6001\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08Dynamic Recurrent Neural Network\uff0c\u7b80\u79f0 DRNN\uff09\u662f\u4e00\u79cd\u5177\u6709\u52a8\u6001\u5b66\u4e60\u80fd\u529b\u7684\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u3002\u5b83\u5728\u4f20\u7edf\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08RNN\uff09\u7684\u57fa\u7840\u4e0a\u5f15\u5165\u4e86\u957f\u77ed\u65f6\u8bb0\u5fc6\uff08Long Short-Term Memory\uff0cLSTM\uff09\u5355\u5143\uff0c\u4ece\u800c\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u5b66\u4e60\u66f4\u957f\u65f6\u95f4\u8de8\u5ea6\u5185\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u63d0\u9ad8\u5bf9\u5e8f\u5217\u6570\u636e\u5efa\u6a21\u7684\u80fd\u529b\u3002<\/p>\n\n\n\n<p>\u52a8\u6001\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08DRNN\uff09\u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. LSTM \u5355\u5143\uff1aDRNN \u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u662f LSTM \u5355\u5143\uff0c\u5b83\u662f\u4e00\u79cd\u5177\u6709\u8bb0\u5fc6\u529f\u80fd\u7684\u795e\u7ecf\u5143\u3002LSTM \u5355\u5143\u901a\u8fc7\u4e09\u4e2a\u95e8\uff08\u8f93\u5165\u95e8\u3001\u9057\u5fd8\u95e8\u548c\u8f93\u51fa\u95e8\uff09\u548c\u4e00\u4e2a\u65b0\u7684\u72b6\u6001\u6765\u63a7\u5236\u4fe1\u606f\u5728\u7f51\u7edc\u4e2d\u7684\u6d41\u52a8\u3002\u8fd9\u79cd\u7ed3\u6784\u4f7f\u5f97 DRNN \u80fd\u591f\u5b66\u4e60\u957f\u65f6\u95f4\u4f9d\u8d56\u5173\u7cfb\uff0c\u540c\u65f6\u907f\u514d\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u95ee\u9898\u3002<\/p>\n\n\n\n<p>2. \u52a8\u6001\u5b66\u4e60\uff1aDRNN \u4e2d\u7684\u52a8\u6001\u5b66\u4e60\u662f\u6307\u7f51\u7edc\u53ef\u4ee5\u6839\u636e\u8f93\u5165\u6570\u636e\u7684\u7279\u5f81\u548c\u957f\u5ea6\u81ea\u52a8\u8c03\u6574\u9690\u85cf\u5c42\u7684\u72b6\u6001\u3002\u8fd9\u4f7f\u5f97 DRNN \u80fd\u591f\u9002\u5e94\u4e0d\u540c\u957f\u5ea6\u548c\u590d\u6742\u5ea6\u7684\u5e8f\u5217\u6570\u636e\u3002<\/p>\n\n\n\n<p>3. \u9690\u85cf\u5c42\uff1aDRNN \u7684\u9690\u85cf\u5c42\u7ed3\u6784\u4e0e\u4f20\u7edf RNN \u7c7b\u4f3c\uff0c\u5305\u542b\u591a\u4e2a\u5c42\u7ea7\u7684\u795e\u7ecf\u5143\u3002\u5728\u6bcf\u4e2a\u65f6\u95f4\u6b65\uff0cLSTM \u5355\u5143\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u9690\u85cf\u72b6\u6001\uff0c\u8be5\u72b6\u6001\u4f1a\u4f5c\u4e3a\u4e0b\u4e00\u5c42\u8f93\u5165\u3002<\/p>\n\n\n\n<p>4. \u6fc0\u6d3b\u51fd\u6570\uff1aDRNN \u4e2d\u7684\u6fc0\u6d3b\u51fd\u6570\u4e0e\u4f20\u7edf RNN \u7c7b\u4f3c\uff0c\u7528\u4e8e\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\u3002\u5e38\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\u6709 sigmoid\u3001ReLU\uff08Rectified Linear Unit\uff09\u7b49\u3002<\/p>\n\n\n\n<p>5. \u635f\u5931\u51fd\u6570\uff1aDRNN \u7684\u635f\u5931\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u8861\u91cf\u6a21\u578b\u9884\u6d4b\u4e0e\u5b9e\u9645\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u8ddd\u3002\u4e0e\u4f20\u7edf RNN \u7c7b\u4f3c\uff0cDRNN \u4e5f\u53ef\u4ee5\u91c7\u7528\u4ea4\u53c9\u71b5\u635f\u5931\uff08Cross-Entropy Loss\uff09\u6216\u5747\u65b9\u8bef\u5dee\u635f\u5931\uff08Mean Squared Error Loss\uff09\u7b49\u4f5c\u4e3a\u635f\u5931\u51fd\u6570\u3002<\/p>\n\n\n\n<p>6. \u8bad\u7ec3\u4e0e\u4f18\u5316\uff1aDRNN \u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u91c7\u7528\u57fa\u4e8e\u68af\u5ea6\u4e0b\u964d\u7684\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08SGD\uff09\u6216 AdaGrad \u7b49\uff0c\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002<\/p>\n\n\n\n<p>7. \u5e94\u7528\uff1aDRNN \u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u7b49\u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u524d\u666f\u3002\u4e0e\u4f20\u7edf RNN \u76f8\u6bd4\uff0cDRNN \u66f4\u64c5\u957f\u5904\u7406\u957f\u5e8f\u5217\u6570\u636e\u548c\u5177\u6709\u590d\u6742\u4f9d\u8d56\u5173\u7cfb\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u52a8\u6001\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff08DRNN\uff09\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u4f20\u7edf RNN \u96be\u4ee5\u5b66\u4e60\u957f\u8ddd\u79bb\u4f9d\u8d56\u7684\u95ee\u9898\uff0c\u5e76\u5728\u8bb8\u591a\u5e94\u7528\u573a\u666f\u4e2d\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u3002\u7136\u800c\uff0cDRNN \u4e5f\u9762\u4e34\u7740\u8ba1\u7b97\u590d\u6742\u5ea6\u9ad8\u3001\u96be\u4ee5\u5e76\u884c\u5904\u7406\u7b49\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u7814\u7a76\u4eba\u5458\u4e00\u76f4\u5728\u63a2\u7d22\u66f4\u9ad8\u6548\u7684\u65b0\u578b DRNN \u7ed3\u6784\u53ca\u5176\u53d8\u79cd\uff0c\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\u548c\u6548\u7387\u3002<\/p>\n\n\n\n<p><strong>\u81ea\u52a8\u7f16\u7801\u5668&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u81ea\u52a8\u7f16\u7801\u5668\uff08AutoEncoder\uff09\u662f\u4e00\u79cd\u76d1\u7763\u5f0f\u5b66\u4e60\u7b97\u6cd5\uff0c\u4e3b\u8981\u7528\u4e8e\u5bf9\u6570\u636e\u8fdb\u884c\u7f16\u7801\u548c\u89e3\u7801\u4efb\u52a1\u3002\u5b83\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u4e09\u5c42\u795e\u7ecf\u7f51\u7edc\uff0c\u5176\u8f93\u5165\u5c42\u548c\u8f93\u51fa\u5c42\u4f7f\u7528\u76f8\u540c\u7684\u6570\u636e\uff0c\u4e2d\u95f4\u5c42\u5219\u7528\u4e8e\u63d0\u53d6\u6570\u636e\u7684\u7279\u5f81\u8868\u793a\u3002\u81ea\u52a8\u7f16\u7801\u5668\u7684\u8bad\u7ec3\u76ee\u6807\u662f\u6700\u5c0f\u5316\u8f93\u5165\u6570\u636e\u548c\u8f93\u51fa\u6570\u636e\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u539f\u59cb\u6570\u636e\u7684\u964d\u7ef4\u548c\u7279\u5f81\u63d0\u53d6\u3002<\/p>\n\n\n\n<p>\u81ea\u52a8\u7f16\u7801\u5668\u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. \u7f16\u7801\u5c42\uff1a\u7f16\u7801\u5c42\u8d1f\u8d23\u4ece\u8f93\u5165\u6570\u636e\u4e2d\u63d0\u53d6\u7279\u5f81\uff0c\u5c06\u539f\u59cb\u6570\u636e\u6620\u5c04\u4e3a\u4f4e\u7ef4\u5ea6\u7684\u7279\u5f81\u8868\u793a\u3002\u7f16\u7801\u5c42\u901a\u5e38\u4f7f\u7528\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\uff0c\u4ee5\u4fdd\u6301\u8f93\u5165\u6570\u636e\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>2. \u538b\u7f29\u5c42\uff1a\u538b\u7f29\u5c42\uff08\u4e5f\u79f0\u4e3a\u74f6\u9888\u5c42\uff09\u662f\u81ea\u52a8\u7f16\u7801\u5668\u7684\u5173\u952e\u90e8\u5206\uff0c\u5b83\u7528\u4e8e\u51cf\u5c11\u7f16\u7801\u5c42\u8f93\u51fa\u7684\u7ef4\u5ea6\uff0c\u4ece\u800c\u5b9e\u73b0\u6570\u636e\u7684\u964d\u7ef4\u3002\u538b\u7f29\u5c42\u901a\u5e38\u91c7\u7528\u975e\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\uff0c\u5982 ReLU\uff08Rectified Linear Unit\uff09\u7b49\uff0c\u4ee5\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\u3002<\/p>\n\n\n\n<p>3. \u89e3\u7801\u5c42\uff1a\u89e3\u7801\u5c42\u8d1f\u8d23\u5c06\u538b\u7f29\u5c42\u8f93\u51fa\u7684\u4f4e\u7ef4\u5ea6\u7279\u5f81\u6620\u5c04\u56de\u539f\u59cb\u6570\u636e\u7684\u9ad8\u7ef4\u5ea6\u7a7a\u95f4\u3002\u89e3\u7801\u5c42\u901a\u5e38\u4f7f\u7528\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\uff0c\u4ee5\u4fdd\u6301\u8f93\u51fa\u6570\u636e\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>4. \u635f\u5931\u51fd\u6570\uff1a\u81ea\u52a8\u7f16\u7801\u5668\u7684\u635f\u5931\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u8861\u91cf\u8f93\u5165\u6570\u636e\u548c\u8f93\u51fa\u6570\u636e\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\u6709\u5747\u65b9\u8bef\u5dee\uff08Mean Squared Error\uff0cMSE\uff09\u548c\u4e8c\u5143\u4ea4\u53c9\u71b5\u635f\u5931\uff08Binary Cross-Entropy Loss\uff09\u7b49\u3002<\/p>\n\n\n\n<p>5. \u8bad\u7ec3\u4e0e\u4f18\u5316\uff1a\u81ea\u52a8\u7f16\u7801\u5668\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u8fdb\u884c\u8bad\u7ec3\uff0c\u4e0d\u65ad\u8c03\u6574\u7f51\u7edc\u53c2\u6570\u4ee5\u6700\u5c0f\u5316\u635f\u5931\u51fd\u6570\u3002\u5e38\u7528\u7684\u4f18\u5316\u7b97\u6cd5\u6709\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08SGD\uff09\u548c Adam \u7b49\u3002<\/p>\n\n\n\n<p>6. \u5e94\u7528\uff1a\u81ea\u52a8\u7f16\u7801\u5668\u5728\u8bb8\u591a\u9886\u57df\u90fd\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5982\u56fe\u50cf\u5904\u7406\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u97f3\u9891\u4fe1\u53f7\u5904\u7406\u7b49\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u7279\u5f81\u63d0\u53d6\u3001\u6570\u636e\u964d\u7ef4\u3001\u5f02\u5e38\u68c0\u6d4b\u7b49\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0c\u81ea\u52a8\u7f16\u7801\u5668\u4e5f\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\uff0c\u5982\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u51fa\u73b0\u8fc7\u5ea6\u62df\u5408\u3001\u7f51\u7edc\u53c2\u6570\u4e0d\u6613\u8c03\u6574\u7b49\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u7814\u7a76\u4eba\u5458\u63d0\u51fa\u4e86\u8bb8\u591a\u6539\u8fdb\u7684\u81ea\u52a8\u7f16\u7801\u5668\u7ed3\u6784\uff0c\u5982\u53d8\u5206\u81ea\u52a8\u7f16\u7801\u5668\uff08Variational AutoEncoder\uff0cVAE\uff09\u3001\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff08Generative Adversarial Network\uff0cGAN\uff09\u7b49\u3002\u8fd9\u4e9b\u6539\u8fdb\u7684\u6a21\u578b\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u63d0\u9ad8\u4e86\u81ea\u52a8\u7f16\u7801\u5668\u7684\u6027\u80fd\u548c\u5e94\u7528\u8303\u56f4\u3002<\/p>\n\n\n\n<p><strong>DCGAN\uff08\u6df1\u5ea6\u5377\u79ef\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff09&nbsp;<\/strong><\/p>\n\n\n\n<p>&nbsp;\u6df1\u5ea6\u5377\u79ef\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff08Deep Convolutional Generative Adversarial Networks\uff0c\u7b80\u79f0 DCGAN\uff09\u662f\u4e00\u79cd\u751f\u6210\u5bf9\u6297\u7f51\u7edc\uff08Generative Adversarial Networks\uff0cGAN\uff09\u7684\u53d8\u4f53\u3002DCGAN \u7684\u6838\u5fc3\u601d\u60f3\u662f\u5c06\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08Convolutional Neural Networks\uff0cCNN\uff09\u4e0e GAN \u76f8\u7ed3\u5408\uff0c\u4ece\u800c\u5728\u56fe\u50cf\u751f\u6210\u4efb\u52a1\u4e2d\u5b9e\u73b0\u66f4\u9ad8\u8d28\u91cf\u7684\u751f\u6210\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>DCGAN \u7684\u4e3b\u8981\u7279\u70b9\u548c\u6982\u5ff5\u5305\u62ec\uff1a<\/p>\n\n\n\n<p>1. \u7ed3\u6784\uff1aDCGAN \u5305\u542b\u4e24\u4e2a\u4e3b\u8981\u90e8\u5206\uff1a\u751f\u6210\u5668\uff08Generator\uff09\u548c\u5224\u522b\u5668\uff08Discriminator\uff09\u3002\u751f\u6210\u5668\u63a5\u6536\u968f\u673a\u566a\u58f0\u4f5c\u4e3a\u8f93\u5165\uff0c\u8f93\u51fa\u751f\u6210\u7684\u56fe\u50cf\uff1b\u5224\u522b\u5668\u5219\u63a5\u6536\u771f\u5b9e\u56fe\u50cf\u548c\u751f\u6210\u56fe\u50cf\u4f5c\u4e3a\u8f93\u5165\uff0c\u8f93\u51fa\u4e8c\u8005\u4e4b\u95f4\u7684\u6982\u7387\u5dee\u5f02\u3002<\/p>\n\n\n\n<p>2. \u5377\u79ef\u64cd\u4f5c\uff1aDCGAN \u4e2d\u7684\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u90fd\u91c7\u7528\u5377\u79ef\u64cd\u4f5c\u4ee3\u66ff\u5168\u8fde\u63a5\u64cd\u4f5c\uff0c\u8fd9\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u66f4\u597d\u5730\u6355\u6349\u56fe\u50cf\u7684\u5c40\u90e8\u7279\u5f81\u548c\u7a7a\u95f4\u7ed3\u6784\u3002\u5377\u79ef\u64cd\u4f5c\u7684\u53e6\u4e00\u4e2a\u4f18\u70b9\u662f\u53ef\u4ee5\u5229\u7528\u9884\u8bad\u7ec3\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u63d0\u9ad8\u751f\u6210\u5bf9\u6297\u7f51\u7edc\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p>3. \u6c60\u5316\u64cd\u4f5c\uff1a\u4e0e\u539f\u59cb GAN \u4e0d\u540c\uff0cDCGAN \u4e2d\u7684\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u90fd\u91c7\u7528\u6c60\u5316\u64cd\u4f5c\uff08\u5982\u6700\u5927\u6c60\u5316\u6216\u5e73\u5747\u6c60\u5316\uff09\u6765\u51cf\u5c0f\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\uff0c\u964d\u4f4e\u8ba1\u7b97\u590d\u6742\u5ea6\u3002<\/p>\n\n\n\n<p>4. \u6fc0\u6d3b\u51fd\u6570\uff1aDCGAN \u4e2d\u7684\u6fc0\u6d3b\u51fd\u6570\u4f7f\u7528 ReLU\uff08Rectified Linear Unit\uff09\uff0c\u5f15\u5165\u975e\u7ebf\u6027\u53d8\u6362\uff0c\u589e\u5f3a\u7f51\u7edc\u7684\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n\n\n\n<p>5. \u635f\u5931\u51fd\u6570\uff1aDCGAN \u7684\u635f\u5931\u51fd\u6570\u901a\u5e38\u91c7\u7528\u4e8c\u5143\u4ea4\u53c9\u71b5\u635f\u5931\uff08Binary Cross-Entropy Loss\uff09\uff0c\u8861\u91cf\u751f\u6210\u56fe\u50cf\u4e0e\u771f\u5b9e\u56fe\u50cf\u4e4b\u95f4\u7684\u5dee\u8ddd\u3002<\/p>\n\n\n\n<p>6. \u8bad\u7ec3\u4e0e\u4f18\u5316\uff1aDCGAN \u901a\u8fc7\u4ea4\u66ff\u8bad\u7ec3\u751f\u6210\u5668\u548c\u5224\u522b\u5668\u6765\u8fdb\u884c\u4f18\u5316\u3002\u751f\u6210\u5668\u7684\u76ee\u6807\u662f\u6b3a\u9a97\u5224\u522b\u5668\uff0c\u4f7f\u5176\u65e0\u6cd5\u533a\u5206\u751f\u6210\u56fe\u50cf\u548c\u771f\u5b9e\u56fe\u50cf\uff1b\u5224\u522b\u5668\u5219\u529b\u6c42\u51c6\u786e\u533a\u5206\u4e8c\u8005\u3002\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u91c7\u7528\u968f\u673a\u68af\u5ea6\u4e0b\u964d\uff08SGD\uff09\u6216 Adam \u7b49\u4f18\u5316\u7b97\u6cd5\u6765\u66f4\u65b0\u7f51\u7edc\u53c2\u6570\u3002<\/p>\n\n\n\n<p>7. \u5e94\u7528\uff1aDCGAN \u5728\u56fe\u50cf\u751f\u6210\u9886\u57df\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6210\u679c\uff0c\u53ef\u4ee5\u7528\u4e8e\u751f\u6210\u903c\u771f\u7684\u56fe\u50cf\u3002\u4f8b\u5982\uff0cDCGAN \u5df2\u7ecf\u6210\u529f\u5e94\u7528\u4e8e\u751f\u6210\u903c\u771f\u7684\u624b\u5199\u6570\u5b57\u3001faces \u7b49\u3002<\/p>\n\n\n\n<p>\u5c3d\u7ba1 DCGAN \u76f8\u5bf9\u4e8e\u539f\u59cb GAN \u6ca1\u6709\u592a\u5927\u7684\u6539\u8fdb\uff0c\u4f46\u5b83\u5728\u56fe\u50cf\u751f\u6210\u4efb\u52a1\u4e2d\u8868\u73b0\u51fa\u66f4\u597d\u7684\u6027\u80fd\u3002\u7136\u800c\uff0cDCGAN \u4ecd\u7136\u9762\u4e34\u4e00\u4e9b\u95ee\u9898\uff0c\u5982\u751f\u6210\u5668\u6536\u655b\u901f\u5ea6\u6162\u3001\u6837\u672c\u4e0d\u5e73\u8861\u7b49\u3002\u7814\u7a76\u4eba\u5458\u4e00\u76f4\u5728\u63a2\u7d22\u6539\u8fdb DCGAN \u7684\u65b9\u6cd5\uff0c\u4ee5\u5b9e\u73b0\u66f4\u9ad8\u8d28\u91cf\u7684\u56fe\u50cf\u751f\u6210\u3002<\/p>\n\n\n\n<p><strong>&nbsp;\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6b65\u9aa4<\/strong><\/p>\n\n\n\n<p>&nbsp;\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1. \u5b89\u88c5 TensorFlow\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u9996\u5148\uff0c\u9700\u8981\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5 TensorFlow\u3002\u53ef\u4ee5\u901a\u8fc7 pip \u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;`pip install tensorflow`\u3002<\/p>\n\n\n\n<p>2. \u5bfc\u5165\u5fc5\u8981\u7684\u5e93\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u5728 Python \u4ee3\u7801\u4e2d\uff0c\u5bfc\u5165\u6240\u9700\u7684 TensorFlow \u5e93\u548c\u5176\u4ed6\u76f8\u5173\u5e93\uff0c\u5982 Numpy\u3001Matplotlib \u7b49\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;import tensorflow as tf&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;import numpy as np&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;import matplotlib.pyplot as plt&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>3. \u51c6\u5907\u6570\u636e\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u6839\u636e\u60a8\u7684\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\uff0c\u51c6\u5907\u597d\u8f93\u5165\u6570\u636e\u548c\u5bf9\u5e94\u7684\u6807\u7b7e\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u60a8\u9700\u8981\u5c06\u56fe\u50cf\u6570\u636e\u548c\u5bf9\u5e94\u7684\u6807\u7b7e\u5b58\u50a8\u4e3a NumPy \u6570\u7ec4\u3002<\/p>\n\n\n\n<p>4. \u6784\u5efa\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u4f7f\u7528 TensorFlow \u6784\u5efa\u60a8\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u3002\u8fd9\u5305\u62ec\u5b9a\u4e49\u6a21\u578b\u7684\u7ed3\u6784\u3001\u5c42\u6570\u3001\u6fc0\u6d3b\u51fd\u6570\u3001\u635f\u5931\u51fd\u6570\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;model = tf.keras.Sequential([&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Conv2D(32, (3, 3), activation=&#8217;relu&#8217;, input_shape=(28, 28, 1)),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.MaxPooling2D((2, 2)),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Conv2D(64, (3, 3), activation=&#8217;relu&#8217;),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.MaxPooling2D((2, 2)),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Conv2D(64, (3, 3), activation=&#8217;relu&#8217;),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Flatten(),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Dense(64, activation=&#8217;relu&#8217;),&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;tf.keras.layers.Dense(10, activation=&#8217;softmax&#8217;)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;])&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>5. \u7f16\u8bd1\u6a21\u578b\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u6307\u5b9a\u6a21\u578b\u7684\u4f18\u5316\u5668\u3001\u635f\u5931\u51fd\u6570\u548c\u8bc4\u4f30\u6307\u6807\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u5206\u7c7b\u4efb\u52a1\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u548c\u51c6\u786e\u7387\u4f5c\u4e3a\u8bc4\u4f30\u6307\u6807\uff1a<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;model.compile(optimizer=&#8217;adam&#8217;,&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loss=&#8217;sparse_categorical_crossentropy&#8217;,&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; metrics=[&#8216;accuracy&#8217;])&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>6. \u8bad\u7ec3\u6a21\u578b\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u4f7f\u7528`model.fit()`\u51fd\u6570\u8bad\u7ec3\u6a21\u578b\u3002\u4f20\u5165\u8bad\u7ec3\u6570\u636e\u3001\u6279\u6b21\u5927\u5c0f\uff08batch_size\uff09\u548c\u8bad\u7ec3\u8f6e\u6570\uff08epochs\uff09\u3002<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;history = model.fit(x_train, y_train, epochs=10, batch_size=32)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>7. \u8bc4\u4f30\u6a21\u578b\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u4f7f\u7528`model.evaluate()`\u51fd\u6570\u8bc4\u4f30\u6a21\u578b\u5728\u6d4b\u8bd5\u6570\u636e\u4e0a\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;test_loss, test_acc = model.evaluate(x_test,&nbsp; y_test, verbose=2)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>8. \u9884\u6d4b\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u4f7f\u7528`model.predict()`\u51fd\u6570\u5bf9\u65b0\u7684\u8f93\u5165\u6570\u636e\u8fdb\u884c\u9884\u6d4b\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8220;`python&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;predict_result = model.predict(x_new)&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&#8220;`<\/p>\n\n\n\n<p>9. \u53ef\u89c6\u5316\u4e0e\u5206\u6790\uff1a&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp;\u6839\u636e\u60a8\u7684\u4efb\u52a1\u548c\u6570\u636e\uff0c\u4f7f\u7528 Matplotlib \u7b49\u5e93\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u635f\u5931\u66f2\u7ebf\u3001\u51c6\u786e\u7387\u7b49\u6307\u6807\uff0c\u4ee5\u5206\u6790\u6a21\u578b\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 TensorFlow \u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u3002\u4e0d\u540c\u7684\u4efb\u52a1\u53ef\u80fd\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574\u6a21\u578b\u7ed3\u6784\u548c\u53c2\u6570\uff0c\u4f46\u57fa\u672c\u6b65\u9aa4\u76f8\u540c\u3002\u4e0d\u65ad\u4f18\u5316\u6a21\u578b\uff0c\u76f4\u81f3\u8fbe\u5230\u6ee1\u610f\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u4e0d\u540c\u7684\u4efb\u52a1\u53ef\u80fd\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574\u6a21\u578b\u7ed3\u6784\u548c\u53c2\u6570\uff0c\u4f46\u57fa\u672c\u6b65\u9aa4\u76f8\u540c\u3002<\/strong><\/p>\n\n\n\n<p>&nbsp;\u4f7f\u7528 TensorFlow \u5b9e\u73b0 \u57fa\u672c \u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p><strong>1. \u5bfc\u5165\u6240\u9700\u5e93&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>2. \u51c6\u5907\u6570\u636e\u96c6&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>3. \u6784\u5efa\u7ebf\u6027\u56de\u5f52\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>4. \u7f16\u8bd1\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>5. \u8bad\u7ec3\u6a21\u578b&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p><strong>6. \u8bc4\u4f30\u6a21\u578b<\/strong><\/p>\n\n\n\n<p>\u4e0d\u540c\u7684\u4efb\u52a1\u53ef\u80fd\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574\u6a21\u578b\u7ed3\u6784\u548c\u53c2\u6570\uff0c\u4f46\u57fa\u672c\u6b65\u9aa4\u76f8\u540c\u3002<\/p>\n\n\n\n<p>\u6b22\u8fce\u6765\u5230TF\u7684\u4e16\u754c\uff01<\/p>\n\n\n\n<p>\u66f4\u591a\u6d4b\u8bd5\u6848\u4f8b\u89c1<\/p>\n\n\n\n<p>http:\/\/www.gitpp.com\/yuanzhongqiao\/TensorFlow-Examples<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6559\u7a0b\u7d22\u5f15 0 &#8211; \u5148\u51b3\u6761\u4ef6 1 &#8211; \u7b80\u4ecb 2 &#8211; \u57fa\u672c\u6a21\u578b 3 &#038;#821 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-641","post","type-post","status-publish","format-standard","hentry","category-tensorflow"],"blocksy_meta":"","_links":{"self":[{"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/posts\/641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/comments?post=641"}],"version-history":[{"count":1,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/posts\/641\/revisions"}],"predecessor-version":[{"id":642,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/posts\/641\/revisions\/642"}],"wp:attachment":[{"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=641"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ai.gitpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}