{"id":71808,"student_id":10,"content":"var inputs = [0, 0];\nvar weights = [0.5, 0.5];\n\nfunction NN (inputs, weights) {\n return sigmoid(inputs[0]*weights[0] + inputs[1]*weights[1]);\n}\n\nfunction train (inputs, target) {\n var output = NN(inputs, weights);\n \n var lose = target - output;\n var error = lose*dsigmoid(output);\n \n weights[0] += 0.2*inputs[0]*error;\n weights[1] += 0.2*inputs[1]*error;\n}\n\nforever(function(){\n print(inputs, 10, 10);\n \n var output = NN(inputs, weights);\n print(output, 10, 30, 'red');\n});\n\nwhen('click', function () {\n inputs = [Number(prompt('?')), Number(prompt('?'))]; \n});\n\nvar d = [\n [3.5, 2.1, 1],\n [3.8, 2.1, 1],\n [3.2, 2.2, 1],\n [3.1, 2.1, 1],\n [3.9, 2.0, 1],\n [3.5, 2.2, 1],\n [3.7, 2.1, 1],\n [3.5, 2.4, 1],\n [3.3, 2.7, 1],\n [3.3, 2.2, 1],\n [5.5, 1.5, -1],\n [5.7, 1.3, -1],\n [5.6, 1.2, -1],\n [5.5, 1.5, -1],\n [5.6, 1.6, -1],\n [5.2, 1.5, -1],\n [5.3, 1.3, -1],\n [5.1, 1.2, -1],\n [5.2, 1.4, -1],\n [5.3, 1.4, -1],\n];\n\nfor (var i=0; i\u003c100; i++) {\n d.forEach((a) =\u003e {\n train([a[0], a[1]], a[2]) \n });\n}","created_at":"2019-06-13T12:20:54.583+08:00","updated_at":"2019-11-11T15:23:32.753+08:00","name":"二分學習","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/71808/9971b6b1970a0e23bfa1902f9febc4a9.jpg"},"parent_id":71802,"plugin":"// sigmoid(x)=tanh(x)\nfunction sigmoid(x) {\n var tanh = (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));\n return tanh; // 雙曲正切函數\n}\n\n// dsigmoid(x)=1-x^2;\n// 參考:http://pynopticon.googlecode.com/svn/trunk/src/vlfeat/toolbox/special/dsigmoid.m\n// 參考:http://en.wikipedia.org/wiki/Sigmoid_function\nfunction dsigmoid(x) {\n return 1.0 - x*x;\n}","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":302,"hashid":"5j3s5my6","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1254189,"file_name":"b.png","project_id":71808,"asset_id":125966,"created_at":"2019-06-13T12:20:54.588+08:00","updated_at":"2019-06-13T12:20:54.588+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦