{"id":103,"date":"2017-10-28T23:17:43","date_gmt":"2017-10-28T15:17:43","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=103"},"modified":"2020-06-20T22:58:48","modified_gmt":"2020-06-20T14:58:48","slug":"%e7%a5%9e%e7%bb%8f%e7%bd%91%e7%bb%9c%e6%bc%94%e7%ae%97-%e5%8d%95%e5%b1%82%e6%84%9f%e7%9f%a5%e5%99%a8","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2017\/10\/28\/%e7%a5%9e%e7%bb%8f%e7%bd%91%e7%bb%9c%e6%bc%94%e7%ae%97-%e5%8d%95%e5%b1%82%e6%84%9f%e7%9f%a5%e5%99%a8\/","title":{"rendered":"\u795e\u7ecf\u7f51\u7edc\u6f14\u7b97\u2014\u2014\u5355\u5c42\u611f\u77e5\u5668"},"content":{"rendered":"<hr \/>\n<h2>\u795e\u7ecf\u7f51\u7edc\u7b80\u4ecb<\/h2>\n<p>\u795e\u7ecf\u7f51\u7edc\u662f\u6307\u4e00\u79cd\u6a21\u62df\u4eba\u7c7b\u795e\u7ecf\u7cfb\u7edf\u6240\u8bbe\u8ba1\u51fa\u6765\u7684\u7a0b\u5e8f\u601d\u60f3\uff0c\u7528\u6765\u6a21\u62df\u4eba\u7c7b\u89c6\u89c9\u3001\u542c\u89c9\u7b49\u7b49\u667a\u6167\u884c\u4e3a\u7684\u539f\u7406\uff0c\u8ba9\u7535\u8111\u53ef\u4ee5\u5177\u6709\u4eba\u7c7b\u667a\u6167\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<p>\u4e0b\u56fe\u662f\u751f\u7269\u795e\u7ecf\u7ec6\u80de\u7684\u7ed3\u6784\u56fe\uff0c\u8fd9\u4e2a\u56fe\u770b\u6765\u9887\u4e3a\u590d\u6742\uff0c\u5982\u679c\u7535\u8111\u7a0b\u5e8f\u771f\u7684\u8981\u6a21\u62df\u8fd9\u4e48\u590d\u6742\u7684\u7ed3\u6784\uff0c\u90a3\u7a0b\u5e8f\u5e94\u8be5\u4e5f\u4f1a\u975e\u5e38\u590d\u6742\u624d\u5bf9\u3002<\/p>\n<p><img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/NeuralCell.jpg\" alt=\"\u751f\u7269\u795e\u7ecf\u7ec6\u80de\u7ed3\u6784\u56fe\" \/><\/p>\n<p>\u8fd8\u597d\u3001\u795e\u7ecf\u7f51\u7edc\u7a0b\u5e8f\u4e0d\u9700\u8981\u53bb\u6a21\u62df\u300c\u7ec6\u80de\u819c\u3001\u7c92\u7ebf\u4f53\u3001\u6838\u7cd6\u4f53\u300d\u7b49\u7b49\u590d\u6742\u7684\u7ed3\u6784\uff0c\u56e0\u4e3a\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u900f\u8fc7\u300c\u62bd\u8c61\u5316\u300d\u5c06\u4e0a\u8ff0\u7684\u795e\u7ecf\u7ec6\u80de\u7ed3\u6784\u7b80\u5316\u6210\u4e0b\u56fe(a) \u7684\u6837\u5b50\u3002<\/p>\n<p>\u5728\u4e0b\u56fe\u4e2d\uff0c$a_1 &#8230; a_n$ \u662f\u8f93\u5165\uff0c$w_1 &#8230; w_n$ \u662f\u6743\u91cd\uff0c\u8fd9\u4e9b\u8f93\u5165\u4e58\u4e0a\u6743\u91cd\u4e4b\u540e\u52a0\u603b(SUM)\uff0c\u5c31\u4f1a\u5f97\u5230\u795e\u7ecf\u5143\u7684\u523a\u6fc0\u5f3a\u5ea6\uff0c\u63a5\u7740\u7ecf\u8fc7\u51fd\u6570f() \u8f6c\u6362\u4e4b\u540e\uff0c\u5c31\u5f97\u5230\u4e86\u8f93\u51fa\u7684\u523a\u6fc0\u5f3a\u5ea6\u3002<\/p>\n<p><img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/NeuralNet1.jpg\" alt=\"\u62bd\u8c61\u534e\u7684\u751f\u7269\u795e\u7ecf\u7ec6\u80de\u7ed3\u6784\u56fe\" \/><\/p>\n<p>\u4e0a\u56fe(a)\u6240\u5bf9\u5e94\u7684\u6570\u5b66\u516c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><center><br \/>\n$t=f(\\vec x\u00b7\\vec a + b) = f\\left(\\sum_{i = 1}^n(w_{i}*a_{i}) + b\\right)$<br \/>\n<\/center><\/p>\n<p>\u5176\u4e2d\u7684b \u503c\u662f\u7528\u4f5c\u9600\u503c\uff0c\u4e3e\u4f8b\u6765\u8bf4\uff0c\u82e5b\u662f-0.5\uff0c\u90a3\u4e48\u5c31\u4ee3\u8868\u8981\u5c06\u603b\u5408\u51cf\u63890.5\uff0c\u624d\u5f97\u5230\u8f93\u5165\u523a\u6fc0\u5f3a\u5ea6\uff0c\u8fd9\u53ef\u4ee5\u7528\u6765\u8c03\u8282\u523a\u6fc0\u5f3a\u5ea6\uff0c\u624d\u4e0d\u4f1a\u4e00\u76f4\u589e\u5f3a\u4e0a\u53bb\u3002<\/p>\n<p>\u800c\u4e0a\u56fe(b) \u4e2d\u7684\u7f51\u7edc\uff0c\u662f\u4e00\u79cd\u5355\u5c42\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u6240\u8c13\u5355\u5c42\u662f\u4e0d\u8ba1\u7b97\u8f93\u5165\u8282\u70b9\u7684\u8ba1\u7b97\u65b9\u5f0f\uff0c\u56e0\u6b64\u53ea\u6709\u56fe\u4e2d\u7684\u5927\u5708\u5708\u624d\u7b97\u662f\u4e00\u5c42\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5927\u5708\u5708\u90fd\u662f\u5982\u56fe(a) \u4e2d\u7684\u4e00\u4e2a\u795e\u7ecf\u5143\u3002<\/p>\n<p>\u6700\u65e9\u7684\u795e\u7ecf\u7f51\u7edc\u7a0b\u5f0f\u79f0\u4e3a\u611f\u77e5\u5668\uff08Perceptron\uff09\uff0c\u8fd9\u662f\u7531Frank Rosenblatt \u57281957 \u5e74\u4e8eCornell \u822a\u7a7a\u5b9e\u9a8c\u5ba4(Cornell Aeronautical Laboratory) \u6240\u53d1\u660e\u7684\u3002<\/p>\n<p>\u4f46\u662f\u57281969 \u5e74\uff0cMarvin Minsky \u548cSeymour Papert\u5728\u300aPerceptrons\u300b\u4e66\u4e2d\uff0c\u4ed4\u7ec6\u5206\u6790\u4e86\u77e5\u5668\u4e3a\u7684\u529f\u80fd\u53ca\u5c40\u9650\uff0c\u8bc1\u660e\u611f\u77e5\u5668\u4e0d\u80fd\u89e3\u51b3\u7b80\u5355\u7684XOR\u7b49\u95ee\u9898\uff0c\u7ed3\u679c\u5bfc\u81f4\u795e\u7ecf\u7f51\u7edc\u6280\u672f\u7ecf\u5386\u4e86\u957f\u8fbe20\u5e74\u7684\u4f4e\u6f6e\u671f\u3002<\/p>\n<p>\u540e\u6765\u57281986 \u5e74\uff0cRumelhart\u7b49\u4eba\u4e8e\u4e0b\u5217\u8bba\u6587\u4e2d\u63d0\u51fa\u300c\u53cd\u5411\u4f20\u64ad\u300d(back-propagation) \u6f14\u7b97\u6cd5\uff0c\u5e76\u6210\u529f\u7684\u88ab\u8fd0\u7528\u5728\u8bed\u97f3\u8fa8\u8bc6\u7b49\u9886\u57df\u4e4b\u540e\uff0c\u795e\u7ecf\u7f51\u7edc\u624d\u53c8\u5f00\u59cb\u6210\u4e3a\u70ed\u95e8\u7684\u7814\u7a76\u4e3b\u9898\u3002<\/p>\n<blockquote style='border:3px double'><p>\nRumelhart, David E.; Hinton, Geoffrey E., Williams, Ronald J. Learning representations by back-propagating errors. Nature. 8 October 1986, 323 (6088): 533\u2013536.\n<\/p><\/blockquote>\n<p>\u4e8b\u5b9e\u4e0a\u3001\u53cd\u5411\u4f20\u64ad\u7684\u65b9\u6cd5\uff0c\u5e76\u4e0d\u662fRumelhart \u7b49\u4eba\u7b2c\u4e00\u4e2a\u63d0\u51fa\u6765\u7684\uff0cPaul J. Werbos 1974 \u5e74\u5728\u54c8\u4f5b\u7684\u535a\u58eb\u8bba\u6587\u4e2d\u5c31\u63d0\u51fa\u4e86\u7c7b\u4f3c\u7684\u65b9\u6cd5\uff0c\u53ea\u662f\u5927\u5bb6\u90fd\u4e0d\u77e5\u9053\u800c\u5df2\u3002<\/p>\n<blockquote style='border:3px double'><p>\nPaul J. Werbos. Beyond Regression: New Tools for Prediction and Analysis in the Behavioral Sciences. PhD thesis, Harvard University, 1974\n<\/p><\/blockquote>\n<p>\u5f53\u7136\uff0c\u795e\u7ecf\u7f51\u7edc\u518d\u5ea6\u6210\u4e3a\u7814\u7a76\u7126\u70b9\u4e4b\u540e\uff0c\u5404\u5f0f\u5404\u6837\u7684\u65b9\u6cd5\u53c8\u88ab\u53d1\u5c55\u51fa\u6765\u4e86\uff0c\u5927\u81f4\u4e0a\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5206\u4e3a\u4e24\u7c7b\uff0c\u4e00\u79cd\u79f0\u4e3a\u300c\u6709\u6307\u5bfc\u8005\u300d\u7684\u795e\u7ecf\u7f51\u7edc(Supervised Neural Network) \uff0c\u50cf\u662f\u300c\u611f\u77e5\u5668\u4e0e\u53cd\u4f20\u9012\u6f14\u7b97\u6cd5\u300d\u7b49\uff0c\u53e6\u4e00\u79cd\u79f0\u4e3a\u300c\u6ca1\u6709\u6307\u5bfc\u8005\u300d\u7684\u795e\u7ecf\u7f51\u7edc(Unsupervised Neural Network)\uff0c\u50cf\u662f\u300c\u970d\u666e\u83f2\u5c14\u5fb7\u7f51\u7edc(Hopfield Network) \u4e0e\u81ea\u7ec4\u7ec7\u795e\u7ecf\u7f51\u7edc(Self Organization network)\u300d\u7b49\u7b49\u3002<\/p>\n<p>\u5f53\u7136\u3001\u795e\u7ecf\u7f51\u7edc\u5e76\u4e0d\u662f\u300c\u795e\u5947\u94f6\u5f39\u300d\uff0c\u53ef\u4ee5\u89e3\u51b3\u4eba\u5de5\u667a\u6167\u4e0a\u7684\u6240\u6709\u95ee\u9898\uff0c\u795e\u7ecf\u7f51\u7edc\u6700\u5f3a\u5927\u7684\u5730\u65b9\u662f\u5bb9\u9519\u6027\u5f88\u5f3a\uff0c\u800c\u4e14\u4e0d\u9700\u8981\u50cf\u4e13\u5bb6\u7cfb\u7edf\u90a3\u6837\u64b0\u5199\u4e00\u5806\u89c4\u5219\uff0c\u4f46\u662f\u6709\u5f97\u5fc5\u6709\u5931\uff0c\u795e\u7ecf\u7f51\u7edc\u81ea\u52a8\u5b66\u4e60\u5b8c\u6210\u4e4b\u540e\uff0c\u6211\u4eec\u6839\u672c\u4e0d\u77e5\u9053\u8be5\u5982\u4f55\u518d\u53bb\u6539\u8fdb\u8fd9\u4e2a\u5b66\u4e60\u6210\u679c\uff0c\u56e0\u4e3a\u90a3\u4e9b\u6743\u91cd\u5bf9\u4eba\u7c7b\u6765\u8bf4\u6839\u672c\u5c31\u6ca1\u6709\u4ec0\u4e48\u76f4\u89c2\u7684\u610f\u4e49\uff0c\u56e0\u6b64\u4e5f\u5c31\u5f88\u96be\u518d\u53bb\u6539\u8fdb\u8fd9\u4e2a\u7f51\u7edc\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u968f\u7740\u79d1\u6280\u7684\u53d1\u5c55\uff0c\u8fd9\u4e9b\u95ee\u9898\u5c06\u4f1a\u6162\u6162\u7684\u88ab\u89e3\u51b3\uff01<\/p>\n<h2>\u5b9e\u4f8b\uff1a\u5355\u5c42\u611f\u77e5\u5668(Perceptron)<\/h2>\n<h4>\u7b80\u4ecb<\/h4>\n<p>Rosenblatt \u4e8e1958 \u5e74\u63d0\u51fa\u4e86\u7b2c\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u79f0\u4e3a\u611f\u77e5\u5668\uff0c\u8fd9\u4e2a\u6a21\u578b\u662f\u57fa\u4e8e1943 \u5e74McCulloch \u4e0ePitts \u6240\u63d0\u51fa\u7684\u795e\u7ecf\u5143\u6a21\u578b\uff0c\u8be5\u6a21\u578b\u7684\u6570\u5b66\u516c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><center><br \/>\n$Y = sign\\left[\\sum_{i-1}^n(x_{i} w_{i}) &#8211; \\theta\\right]$<br \/>\n<\/center><\/p>\n<p>\u5176\u4e2d\u7684sign \u662f\u6b63\u8d1f\u53f7\u5224\u65ad\u51fd\u6570\uff0c\u82e5\u662f\u6b63\u6570\u5219\u4f20\u56de1\uff0c\u8d1f\u6570\u5219\u4f20\u56de0\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u5728\u6b64\u6211\u4eec\u6240\u8bf4\u7684\u300c\u611f\u77e5\u5668\u300d\u662f\u6307Rosenblatt \u5f53\u65f6\u6240\u4f7f\u7528\u7684\u611f\u77e5\u5668\uff0c\u7279\u6307\u53ea\u6709\u4e00\u5c42\u8282\u70b9\u7684\u300c\u5355\u5c42\u611f\u77e5\u5668\u300d\uff0c\u800c\u4e0d\u662f\u6307\u79f0\u90a3\u79cd\u5177\u6709\u9690\u85cf\u5c42\u7684\u300c\u591a\u5c42\u611f\u77e5\u5668\u300d (Multilayer Perceptron)\uff0c\u8fd9\u70b9\u5fc5\u987b\u7279\u522b\u6f84\u6e05\u4e00\u4e0b\uff01<\/p>\n<p>\u800c\u6240\u8c13\u611f\u77e5\u5668\u7684\u5b66\u4e60\uff0c\u5c31\u662f\u900f\u8fc7\u8c03\u6574\u6743\u91cd$w_i$ \u7684\u65b9\u5f0f\uff0c\u8ba9\u6574\u4e2a\u7f51\u7edc\u53ef\u4ee5\u5b66\u5230\u67d0\u4e2a\u51fd\u6570\u7684\u65b9\u6cd5\uff0c\u6240\u4ee5\u6743\u91cd\u7684\u8c03\u6574\u65b9\u6cd5\u662f\u6574\u4e2a\u611f\u77e5\u5668\u5b66\u4e60\u884c\u4e3a\u7684\u6838\u5fc3\u3002<\/p>\n<h4>\u611f\u77e5\u5668\u7684\u5b66\u4e60<\/h4>\n<p>\u4ee5\u4e0b\u662f\u611f\u77e5\u5668\u5b66\u4e60\u7684\u6f14\u7b97\u6cd5\uff1a<\/p>\n<ol>\n<li>\u521d\u59cb\u5316\uff1a\u8bbe\u5b9a\u6743\u91cd$w_1,w_2,..w_n$\u548c\u4e34\u754c\u503c$\\theta$\u7684\u521d\u503c\u4e4b\u8303\u56f4\u4e3a[-0.5, 0.5]\u3002<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u52b1\uff1a\u7528\u8f93\u5165$\\left(x_1,x_2,&#8230;x_n\\right)$\u3001\u6743\u91cd$w_1,w_2,..w_n$\u4e0e\u9600\u503c$\\theta$\u8ba1\u7b97\u611f\u77e5\u5668\u7684\u8f93\u51fa\u503cY\u3002<\/p>\n<\/li>\n<\/ol>\n<p><center><br \/>\n$Y = sign\\left[\\sum_{i-1}^n(x_{i} w_{i}) &#8211; \\theta\\right]$<br \/>\n<\/center><\/p>\n<ol start=\"3\">\n<li>\u6743\u91cd\u4fee\u6539\uff1a\u6839\u636e\u51fd\u6570\u8f93\u51fa$Y_d$ \u4e0e\u611f\u77e5\u5668\u8f93\u51faY \u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u8fdb\u884c\u6743\u91cd\u8c03\u6574\u3002\n<p>3.1 \u8ba1\u7b97\u8bef\u5dee\uff1a $e = Y_d &#8211; Y$<\/p>\n<p>3.2 \u8ba1\u7b97\u8c03\u6574\u91cf\uff1a $\\Delta w_i = \\alpha * x_i * e$<\/p>\n<p>3.3 \u8c03\u6574\u6743\u91cd\uff1a $w_i = w_i + \\Delta w_i$<\/p>\n<\/li>\n<li>\n<p>\u91cd\u590d2-3 \u6b65\u9aa4\uff0c\u76f4\u5230\u5b66\u4f1a\u4e3a\u6b62(\u5982\u679c\u4e00\u76f4\u5b66\u4e0d\u4f1a\uff0c\u53ea\u597d\u5ba3\u544a\u5931\u8d25)\u3002<\/p>\n<\/li>\n<\/ol>\n<h4>\u611f\u77e5\u5668\u6a21\u578b(\u4e24\u4e2a\u8f93\u5165\u7684\u60c5\u51b5)<\/h4>\n<p>\u6839\u636e\u4ee5\u4e0a\u7684\u65b9\u6cd5\uff0c\u5047\u5982\u611f\u77e5\u5668\u7684\u8f93\u5165\u53ea\u6709\u4e24\u4e2a$\\left(x_1,x_2\\right)$\u90a3\u4e48\u6743\u91cd\u4e5f\u53ea\u4f1a\u6709\u4e24\u4e2a$\\left(w_1,w_2\\right)$\uff0c\u4e8e\u662f\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u4e0b\u5217\u7684\u611f\u77e5\u5668\u6a21\u578b\uff1a<\/p>\n<p><img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/perceptron.jpg\" alt=\"\u611f\u77e5\u5668\u7ed3\u6784\u6a21\u578b\" \/><\/p>\n<p>\u5047\u5982\u6211\u4eec\u7684\u76ee\u6807\u51fd\u6570\u5bf9\u4e8e\u67d0\u7ec4$\\left(x_1,x_2\\right)$\u7684\u671f\u671b\u8f93\u51fa\u4e3a$y_d$\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u8ba1\u7b97\u51fa\u8bef\u5dee\u4e3a$e=y_d-y$\uff0c\u4e8e\u662f\u6211\u4eec\u53ef\u4ee5\u900f\u8fc7\u4e0b\u5217\u65b9\u6cd5\u8c03\u6574\u6743\u91cd:<\/p>\n<p><center><br \/>\n$w_1 = \\alpha * x_1 * e$<br \/>\n<\/center><\/p>\n<p><center><br \/>\n$w_2 = \\alpha * x_2 * e$<br \/>\n<\/center><\/p>\n<p>\u53ef\u60dc\u7684\u662f\u3001\u4e0a\u8ff0\u7684\u8c03\u6574\u65b9\u6cd5\u4e2d\uff0c\u5e76\u6ca1\u6709\u8c03\u6574\u5230$\\theta$\u503c\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u8fde$\\theta$\u503c\u4e5f\u4e00\u5e76\u8bbe\u8ba1\u6210\u53ef\u6d6e\u52a8\u7684\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u5c06$\\theta$\u52a0\u5165\u5230w\u4e2d\uff0c\u6210\u4e3a$w_0$\uff0c\uff0c\u5e76\u5c06$x_0$\u8bbe\u4e3a- 1\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/perceptron2.jpg\" alt=\"\u611f\u77e5\u5668\u7ed3\u6784\u56fe\" \/><\/p>\n<p>\u7ecf\u8fc7\u4e0a\u8ff0\u7684\u8c03\u6574\u7b80\u5316\u4e4b\u540e\uff0c\u6211\u4eec\u53ea\u8981\u5728\u8c03\u6574\u6743\u91cd\u65f6\u52a0\u5165\u4e0b\u5217\u8fd9\u6761\uff0c\u5c31\u53ef\u4ee5\u8fde\u4e5f\u4e00\u5e76\u8c03\u6574\u4e86\u3002<\/p>\n<p><center><br \/>\n$w_0 = \\alpha * x_0 * e$<br \/>\n<\/center><\/p>\n<p>\u90a3\u4e48\u6709\u51e0\u4e2a\u95ee\u9898\uff0c\u9700\u8981\u601d\u8003\uff1a<\/p>\n<p>\u5f53\u6211\u4eec\u5bf9\u67d0\u5e03\u6797\u51fd\u6570\u300c\u771f\u503c\u300d\u4e2d\u7684\u6bcf\u4e00\u4e2a\u8f93\u5165\uff0c\u90fd\u53cd\u8986\u8fdb\u884c\u4e0a\u8ff0\u8c03\u6574\uff0c\u6700\u540e\u662f\u5426\u80fd\u5b66\u4f1a\u8be5\u300c\u5e03\u6797\u51fd\u6570\u300d\u5462\uff1f<\/p>\n<p>\u90a3\u4e48\u3001\u6211\u4eec\u662f\u5426\u80fd\u591f\u7528\u8fd9\u4e48\u7b80\u5355\u7684\u65b9\u6cd5\u8ba9\u611f\u77e5\u5668\u5b66\u4f1aAND\u3001OR \u4e0eXOR \u51fd\u6570\u5462\uff1f<\/p>\n<p>\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\uff0c\u90a3\u4e48\u6211\u4eec\u80fd\u4e0d\u80fd\u6269\u5927\u5230n \u8f93\u5165\u7684\u611f\u77e5\u5668\u4e0a\uff0c\u8ba9\u611f\u77e5\u5668\u5b66\u4f1a\u4efb\u4f55\u4e00\u4e2a\u5e03\u6797\u51fd\u6570\u5462\uff1f<\/p>\n<p>\u5982\u679c\u611f\u77e5\u5668\u53ef\u4ee5\u5b66\u4f1a\u4efb\u4f55\u4e00\u4e2a\u5e03\u6797\u51fd\u6570\uff0c\u90a3\u5c31\u4f1a\u5177\u6709\u5f3a\u5927\u7684\u5a01\u529b\u4e86\uff01<\/p>\n<p>\u4f46\u53ef\u60dc\u7684\u662f\uff0c\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\u662f\u5426\u5b9a\u7684\uff0c\u867d\u7136\u611f\u77e5\u5668\u53ef\u4ee5\u5b66\u4f1aAND \u4e0eOR\uff0c\u4f46\u662f\u5374\u4e0d\u53ef\u80fd\u5b66\u4f1aXOR \u51fd\u6570\u3002<\/p>\n<p>\u5728\u8bf4\u660e\u8fd9\u4e2a\u95ee\u9898\u7684\u7406\u8bba\u4e4b\u524d\uff0c\u5148\u8ba9\u6211\u4eec\u900f\u8fc7\u5b9e\u4f5c\u6765\u4f53\u4f1a\u4e00\u4e0b\u611f\u77e5\u5668\u662f\u5982\u4f55\u5b66\u4e60AND \u4e0eOR \u51fd\u6570\u7684\uff0c\u7136\u540e\u611f\u53d7\u4e00\u4e0b\u611f\u77e5\u5668\u5728\u5b66XOR \u51fd\u6570\u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\u95ee\u9898\uff1f<\/p>\n<p>\u9700\u8981\u4e86\u89e3\u4e86\u7a0b\u5e8f\u7684\u8fd0\u4f5c\u539f\u7406\u4e4b\u540e\uff0c\u518d\u6765\u8bf4\u660e\u4e3a\u4f55\u611f\u77e5\u5668\u65e0\u6cd5\u5b66\u4f1aXOR \u51fd\u6570\u3002<\/p>\n<h3>\u611f\u77e5\u5668\u5b9e\u4f8b<\/h3>\n<p>\u4ee5\u4e0b\u662f\u5b9e\u4f8b\u611f\u77e5\u5668\u4ee3\u7801\uff0c\u5728node.js \u73af\u5883\u4e0b\u6267\u884c\u6b64\u4e00\u7a0b\u5f0f\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">var log = console.log;\n\nvar Perceptron = function() { \/\/ \u611f\u77e5\u5668\n  this.step=function(x, w) { \/\/  \u8ba1\u7b97\u76ee\u524d\u6743\u91cdw\u7684\u60c5\u51b5\u4e0b\uff0c\u7f51\u7edc\u7684\u8f93\u51fa\u503c\u4e3a0\u62161\n    var result = w[0]*x[0]+w[1]*x[1]+w[2]*x[2]; \/\/ y=w0*x0+x1*w1+x2*w2=-theta+x1*w1+x2*w2\n    if (result &gt;= 0) \/\/ \u5982\u679c\u7ed3\u679c\u5927\u4e8e\u96f6\n      return 1;      \/\/   \u5c31\u8f93\u51fa 1\n    else             \/\/ \u5426\u5219\n      return 0;      \/\/   \u5c31\u8f93\u51fa 0\n  }\n\n  this.training=function(truthTable) { \/\/ \u8bad\u7ec3\u51fd\u6570training\uff08truthTable\uff09\uff0c\u5176\u4e2dtruthTable\u662f\u76ee\u6807\u7684\u771f\u503c\n    var rate = 0.01; \/\/ \u5b66\u4e60\u901f\u7387\u8c03\u6574\uff0c\u4e5f\u5c31\u662falpha\n    var w = [ 1, 0, 0 ]; \n    for (var loop=0; loop&lt;1000; loop++) { \/\/ \u6700\u591a\u8bad\u7ec3\u4e00\u5343\u8f6e\n      var eSum = 0.0;\n      for (var i=0; i&lt;truthTable.length; i++) { \/\/ \u6bcf\u8f6e\u5bf9\u4e8e\u771f\u503c\u4e2d\u7684\u6bcf\u4e2a\u8f93\u5165\u8f93\u51fa\u914d\u5bf9\uff0c\u90fd\u8bad\u7ec3\u4e00\u6b21\u3002\n        var x = [ -1, truthTable[i][0], truthTable[i][1] ]; \/\/ \u8f93\u5165\uff1a x\n        var yd = truthTable[i][2];       \/\/ \u671f\u671b\u7684\u8f93\u51fa yd\n        var y = this.step(x, w);  \/\/ \u76ee\u524d\u7684\u8f93\u51fa y\n        var e = yd - y;                  \/\/ \u5dee\u8ddd e = \u671f\u671b\u7684\u8f93\u51fa yd - \u76ee\u524d\u7684\u8f93\u51fa y\n        eSum += e*e;                     \/\/ \u8ba1\u7b97\u5dee\u8ddd\u603b\u548c\n        var dw = [ 0, 0, 0 ];            \/\/ \u6743\u91cd\u8c03\u6574\u7684\u5e45\u5ea6dw\n        dw[0] = rate * x[0] * e; w[0] += dw[0]; \/\/ w[0] \u7684\u8c03\u6574\u5e45\u5ea6\u4e3a dw[0]\n        dw[1] = rate * x[1] * e; w[1] += dw[1]; \/\/ w[1] \u7684\u8c03\u6574\u5e45\u5ea6\u4e3a dw[1]\n        dw[2] = rate * x[2] * e; w[2] += dw[2]; \/\/ w[2] \u7684\u8c03\u6574\u5e45\u5ea6\u4e3a dw[2]\n        if (loop % 10 == 0)\n          log(\"%d:x=(%s,%s,%s) w=(%s,%s,%s) y=%s yd=%s e=%s\", loop, \n               x[0].toFixed(3), x[1].toFixed(3), x[2].toFixed(3), \n               w[0].toFixed(3), w[1].toFixed(3), w[2].toFixed(3), \n               y.toFixed(3), yd.toFixed(3), e.toFixed(3));\n      }\n      if (Math.abs(eSum) &lt; 0.0001) return w; \/\/ \u5f53\u8bad\u7ec3\u7ed3\u679c\u8bef\u5dee\u591f\u5c0f\u65f6\uff0c\u5c31\u5b8c\u6210\u8bad\u7ec3\u4e86\u3002\n    }\n    return null; \/\/ \u5426\u5219\uff0c\u5c31\u4f20\u4f1anull\u4ee3\u8868\u8bad\u7ec3\u5931\u8d25\u3002\n  }\n}\n\nfunction learn(tableName, truthTable) { \/\/ \u5b66\u4e60\u4e3b\u7a0b\u5f0f\uff1a\u8f93\u5165\u4e3a\u76ee\u6807\u7684\u771f\u503ctruthTable\u4e0e\u5176\u540d\u79f0tableName\u3002\n  log(\"================== \u5b66\u4e60 %s \u51fd\u6570 ====================\", tableName);\n  var p = new Perceptron();       \/\/ \u5efa\u7acb\u611f\u77e5\u5668\n  var w = p.training(truthTable); \/\/ \u8bad\u7ec3\u4f20\u611f\u5668\n  if (w != null)                  \/\/ \u663e\u793a\u8bad\u7ec3\u7ed3\u679c\n    log(\"\u5b66\u4e60\u6210\u529f !\");\n  else\n    log(\"\u5b66\u4e60\u5931\u8d25 !\");\n  log(\"w=%j\", w);\n}\n\nvar andTable = [ [ 0, 0, 0 ], [ 0, 1, 0 ], [ 1, 0, 0 ], [ 1, 1, 1 ] ]; \/\/ AND\u51fd\u6570\u7684\u771f\u503c\nvar orTable  = [ [ 0, 0, 0 ], [ 0, 1, 1 ], [ 1, 0, 1 ], [ 1, 1, 1 ] ]; \/\/ OR\u51fd\u6570\u7684\u771f\u503c\nvar xorTable = [ [ 0, 0, 0 ], [ 0, 1, 1 ], [ 1, 0, 1 ], [ 1, 1, 0 ] ]; \/\/ XOR\u51fd\u6570\u7684\u771f\u503c\n\nlearn(\"and\", andTable); \/\/ \u5b66\u4e60AND\u51fd\u6570\nlearn(\"or\",  orTable);  \/\/ \u5b66\u4e60OR\u51fd\u6570\nlearn(\"xor\", xorTable); \/\/ \u5b66\u4e60XOR\u51fd\u6570\n<\/code><\/pre>\n<p>\u6267\u884c\u7ed3\u679c\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">================== \u5b66\u4e60 and \u51fd\u6570 ====================\n0:x=(-1.000,0.000,0.000) w=(1.000,0.000,0.000) y=0.000 yd=0.000 e=0.000\n0:x=(-1.000,0.000,1.000) w=(1.000,0.000,0.000) y=0.000 yd=0.000 e=0.000\n0:x=(-1.000,1.000,0.000) w=(1.000,0.000,0.000) y=0.000 yd=0.000 e=0.000\n0:x=(-1.000,1.000,1.000) w=(0.990,0.010,0.010) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,0.000,0.000) w=(0.900,0.100,0.100) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,0.000,1.000) w=(0.900,0.100,0.100) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,1.000,0.000) w=(0.900,0.100,0.100) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,1.000,1.000) w=(0.890,0.110,0.110) y=0.000 yd=1.000 e=1.000\n20:x=(-1.000,0.000,0.000) w=(0.800,0.200,0.200) y=0.000 yd=0.000 e=0.000\n20:x=(-1.000,0.000,1.000) w=(0.800,0.200,0.200) y=0.000 yd=0.000 e=0.000\n20:x=(-1.000,1.000,0.000) w=(0.800,0.200,0.200) y=0.000 yd=0.000 e=0.000\n20:x=(-1.000,1.000,1.000) w=(0.790,0.210,0.210) y=0.000 yd=1.000 e=1.000\n30:x=(-1.000,0.000,0.000) w=(0.700,0.300,0.300) y=0.000 yd=0.000 e=0.000\n30:x=(-1.000,0.000,1.000) w=(0.700,0.300,0.300) y=0.000 yd=0.000 e=0.000\n30:x=(-1.000,1.000,0.000) w=(0.700,0.300,0.300) y=0.000 yd=0.000 e=0.000\n30:x=(-1.000,1.000,1.000) w=(0.690,0.310,0.310) y=0.000 yd=1.000 e=1.000\n\u5b66\u4e60\u6210\u529f !\nw=[0.6599999999999997,0.34000000000000014,0.34000000000000014]\n================== \u5b66\u4e60 or \u51fd\u6570 ====================\n0:x=(-1.000,0.000,0.000) w=(1.000,0.000,0.000) y=0.000 yd=0.000 e=0.000\n0:x=(-1.000,0.000,1.000) w=(0.990,0.000,0.010) y=0.000 yd=1.000 e=1.000\n0:x=(-1.000,1.000,0.000) w=(0.980,0.010,0.010) y=0.000 yd=1.000 e=1.000\n0:x=(-1.000,1.000,1.000) w=(0.970,0.020,0.020) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,0.000,0.000) w=(0.700,0.200,0.200) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,0.000,1.000) w=(0.690,0.200,0.210) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,1.000,0.000) w=(0.680,0.210,0.210) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,1.000,1.000) w=(0.670,0.220,0.220) y=0.000 yd=1.000 e=1.000\n20:x=(-1.000,0.000,0.000) w=(0.460,0.340,0.340) y=0.000 yd=0.000 e=0.000\n20:x=(-1.000,0.000,1.000) w=(0.450,0.340,0.350) y=0.000 yd=1.000 e=1.000\n20:x=(-1.000,1.000,0.000) w=(0.440,0.350,0.350) y=0.000 yd=1.000 e=1.000\n20:x=(-1.000,1.000,1.000) w=(0.440,0.350,0.350) y=1.000 yd=1.000 e=0.000\n\u5b66\u4e60\u6210\u529f !\nw=[0.37999999999999945,0.38000000000000017,0.38000000000000017]\n================== \u5b66\u4e60 xor \u51fd\u6570 ====================\n0:x=(-1.000,0.000,0.000) w=(1.000,0.000,0.000) y=0.000 yd=0.000 e=0.000\n0:x=(-1.000,0.000,1.000) w=(0.990,0.000,0.010) y=0.000 yd=1.000 e=1.000\n0:x=(-1.000,1.000,0.000) w=(0.980,0.010,0.010) y=0.000 yd=1.000 e=1.000\n0:x=(-1.000,1.000,1.000) w=(0.980,0.010,0.010) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,0.000,0.000) w=(0.800,0.100,0.100) y=0.000 yd=0.000 e=0.000\n10:x=(-1.000,0.000,1.000) w=(0.790,0.100,0.110) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,1.000,0.000) w=(0.780,0.110,0.110) y=0.000 yd=1.000 e=1.000\n10:x=(-1.000,1.000,1.000) w=(0.780,0.110,0.110) y=0.000 yd=0.000 e=0.000\n...\n900:x=(-1.000,0.000,0.000) w=(0.010,-0.010,-0.000) y=1.000 yd=0.000 e=-1.000\n900:x=(-1.000,0.000,1.000) w=(-0.000,-0.010,0.010) y=0.000 yd=1.000 e=1.000\n900:x=(-1.000,1.000,0.000) w=(-0.010,-0.000,0.010) y=0.000 yd=1.000 e=1.000\n900:x=(-1.000,1.000,1.000) w=(-0.000,-0.010,-0.000) y=1.000 yd=0.000 e=-1.000\n...\n990:x=(-1.000,0.000,0.000) w=(0.010,-0.010,-0.000) y=1.000 yd=0.000 e=-1.000\n990:x=(-1.000,0.000,1.000) w=(-0.000,-0.010,0.010) y=0.000 yd=1.000 e=1.000\n990:x=(-1.000,1.000,0.000) w=(-0.010,-0.000,0.010) y=0.000 yd=1.000 e=1.000\n990:x=(-1.000,1.000,1.000) w=(-0.000,-0.010,-0.000) y=1.000 yd=0.000 e=-1.000\n\u5b66\u4e60\u5931\u8d25 !\nw=null\n<\/code><\/pre>\n<h4>\u5206\u6790<\/h4>\n<p>\u60a8\u53ef\u4ee5\u770b\u5230\u5728\u4e0a\u8ff0\u6267\u884c\u7ed3\u679c\u4e2d\uff0c AND \u4e0eOR \u4e24\u4e2a\u771f\u503c\uff0c\u8f93\u5165\u5230\u5355\u5c42\u611f\u77e5\u5668\u8fdb\u884c\u8bad\u7ec3\u4e4b\u540e\uff0c\u90fd\u53ef\u4ee5\u6b63\u786e\u7684\u8fdb\u884c\u5b66\u4e60\uff0c\u4e5f\u5c31\u662f\u5355\u5c42\u611f\u77e5\u5668\u7684\u8f93\u51fa\u53ef\u4ee5\u4e0e\u8be5\u771f\u503c\u5b8c\u5168\u4e00\u81f4\uff0c\u8fd9\u4ee3\u8868\u5355\u5c42\u611f\u77e5\u5668\u5b66\u4e60\u6210\u529f\u4e86\u3002<\/p>\n<p>\u4f46\u662f\u5bf9\u4e8eXOR \u8fd9\u4e2a\u771f\u503c\uff0c\u5355\u5c42\u611f\u77e5\u5668\u5374\u65e0\u6cd5\u8ba9\u8f93\u51fa\u4e0e\u771f\u503c\u5b8c\u5168\u4e00\u81f4\uff0c\u8fd9\u4e5f\u6b63\u662fMinsky \u6240\u8bf4\u7684\uff0c\u5355\u5c42\u611f\u77e5\u5668\u65e0\u6cd5\u6b63\u786e\u5b66\u4e60XOR \u51fd\u6570\u7684\u539f\u56e0\u3002<\/p>\n<p>\u4f1a\u4ea7\u751f\u8fd9\u4e2a\u73b0\u8c61\u7684\u539f\u56e0\uff0c\u53ef\u4ee5\u7528\u7ebf\u6027\u4ee3\u6570\u7684\u6982\u5ff5\u89e3\u91ca\uff0c\u4e0b\u56fe\u663e\u793a\u4e86AND, OR, XOR \u7b49\u8fd9\u4e09\u4e2a\u771f\u503c\u5728\u4e8c\u7ef4\u7ebf\u6027\u7a7a\u95f4\u7684\u72b6\u51b5\uff0c\u5176\u4e2d\u7684\u7c89\u7ea2\u8272\u5706\u5708\u4ee3\u8868\u771f\u503c\u7684\u76ee\u6807\u8f93\u51fa\u503c\u4e3a1\uff0c\u800c\u6d45\u84dd\u8272\u5706\u5708\u4ee3\u8868\u76ee\u6807\u8f93\u51fa\u4e3a0\u3002<\/p>\n<p><img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/perceptronLinearAnalysis.jpg\" alt=\"\u751f\u7269\u795e\u7ecf\u7ec6\u80de\u7ed3\u6784\u56fe\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u770b\u5230\u5bf9\u4e8eAND \u4e0eOR \u90fd\u53ef\u4ee5\u7528\u4e00\u6761\u7ebf\u5c06\u300c\u7c89\u7ea2\u8272\u5706\u5708\u300d\u4e0e\u300c\u6d45\u84dd\u8272\u5706\u5708\u300d\u5206\u5272\u5f00\u6765\u3002\u4f46\u662f\u5bf9XOR \u800c\u8a00\uff0c\u7531\u4e8e\u7c89\u7ea2\u8272\u4e0e\u6d45\u84dd\u8272\u5206\u522b\u5904\u4e8e\u659c\u5bf9\u89d2\uff0c\u6211\u4eec\u6ca1\u6709\u529e\u6cd5\u753b\u51fa\u5355\u4e00\u6761\u7ebf\u5c06\u4e24\u8005\u5206\u5f00\uff0c\u8fd9\u4e5f\u662f\u4f1a\u4f55\u4e0a\u8ff0\u5355\u5c42\u611f\u77e5\u5668\u5728\u5b66\u4e60XOR \u8fd9\u4e2a\u51fd\u6570\u4e0a\u4f1a\u5931\u8d25\u7684\u539f\u56e0\u4e86\u3002<\/p>\n<h4>\u7ed3\u8bed<\/h4>\n<p>\u53ef\u60dc\u7684\u662f\uff0c\u5355\u5c42\u611f\u77e5\u5668\u5e76\u6ca1\u6709\u529e\u6cd5\u5b66\u4f1a\u4efb\u610f\u7684\u5e03\u6797\u51fd\u6570\uff0c\u8fd9\u4e2a\u7ed3\u679c\u867d\u7136\u4ee4\u4eba\u5931\u671b\uff0c\u4f46\u662f\u671f\u671b\u8fd9\u4e48\u7b80\u5355\u7684\u6a21\u578b\u5c31\u80fd\u62e5\u6709\u5f3a\u5927\u7684\u80fd\u529b\uff0c\u5176\u5b9e\u662f\u4e00\u79cd\u975e\u5e38\u5929\u771f\u7684\u60f3\u6cd5\u3002<\/p>\n<p>\u4e0d\u8fc7\u3001\u5982\u679c\u6211\u4eec\u5c06\u8fd9\u79cd\u5355\u5c42\u7684\u7f51\u7edc\u7ee7\u7eed\u6269\u5145\uff0c\u53d8\u6210\u53cc\u5c42\u4ee5\u4e0a\u7684\u7f51\u7edc\u7684\u8bdd\uff0c\u5176\u80fd\u529b\u5c31\u4f1a\u5927\u5927\u7684\u63d0\u5347\u4e86\uff0c\u8fd9\u4e5f\u5c31\u662f\u6211\u4eec\u63a5\u4e0b\u6765\u8981\u63a2\u8ba8\u7684\u4e3b\u9898\uff0c\u53cd\u4f20\u9012\u6f14\u7b97\u6cd5(Back -Propagation Algorithm) \u4e86\u3002<\/p>\n<p>code enjoy\uff01 \ud83d\ude42<\/p>\n<p>\u4f5c\u8005\uff1aindeex<\/p>\n<p>\u94fe\u63a5\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/indeex.cc\/\">http:\/\/indeex.cc<\/a><\/p>\n<p>\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u795e\u7ecf\u7f51\u7edc\u7b80\u4ecb \u795e\u7ecf\u7f51\u7edc\u662f\u6307\u4e00\u79cd\u6a21\u62df\u4eba\u7c7b\u795e\u7ecf\u7cfb\u7edf\u6240\u8bbe\u8ba1\u51fa\u6765\u7684\u7a0b\u5e8f\u601d\u60f3\uff0c\u7528\u6765\u6a21\u62df\u4eba\u7c7b\u89c6\u89c9\u3001\u542c\u89c9\u7b49\u7b49\u667a\u6167\u884c<a href=\"https:\/\/blog.indeex.club\/index.php\/2017\/10\/28\/%e7%a5%9e%e7%bb%8f%e7%bd%91%e7%bb%9c%e6%bc%94%e7%ae%97-%e5%8d%95%e5%b1%82%e6%84%9f%e7%9f%a5%e5%99%a8\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/103"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}