{"id":76527,"student_id":1409,"content":"function activation(x) {\n return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));\n}\n\nfunction dactivation(x) {\n return 1.0 - x*x;\n}\n\nvar ia = 0; //輸入:耳朵長度\nvar ib = 0; //輸入:尾巴長度\nvar wa = 0; //權重:耳朵長度\nvar wb = 0; //權重尾巴長度\nvar rate = 0.01; // 速率\n\n// 訓練感知器的假資料 [耳朵長度, 尾巴長度, 物種]\nvar data = [\n //一般貓咪\n [3.5, 12.1, 1],\n [3.8, 12.3, 1],\n [3.2, 12.5, 1],\n [4.0, 13.1, 1],\n [3.9, 13.0, 1],\n [3.5, 12.7, 1],\n [3.7, 12.8, 1],\n [3.5, 12.9, 1],\n [3.3, 12.3, 1],\n [3.3, 12.9, 1],\n //一般兔子\n [9.1, 7.2, -1],\n [8.7, 7.4, -1],\n [9.3, 7.6, -1],\n [9.2, 7.1, -1],\n [9.0, 7.9, -1],\n [9.1, 6.8, -1],\n [8.5, 7.8, -1],\n [8.6, 8.1, -1],\n [8.9, 8.3, -1],\n [8.8, 7.9, -1],\n];\n\n\n// 繪圖 \u0026 顯示數值\nforever(function() {\n pen.fillColor = 'black';\n pen.drawLine(100, 100, 300, 240);\n pen.drawLine(100, 380, 300, 240);\n pen.drawLine(300, 240, 450, 240);\n pen.drawCircle(100, 100, 20);\n pen.drawCircle(100, 380, 20);\n pen.drawCircle(300, 240, 20);\n \n var output = NN(ia, ib, wa, wb);\n print('i1: ' + ia, 90, 60, 'blue');\n print('i2: ' + ib, 90, 340, 'blue');\n print('w1: ' + wa, 200, 170, 'red');\n print('w1: ' + wb, 200, 310, 'red');\n print(output, 455, 230, 'green');\n \n cat.opacity = (output+1)/2;\n rabbit.opacity = 1- (output+1)/2;\n});\n\n// 感知器\nfunction NN (input_a, input_b, weight_a, weight_b) {\n \n var output= input_a* weight_a+ input_b* weight_b\n output= activation(output)\n return output\n}\n\n// 訓練\nfunction train (input_a, input_b, target) {\n var output = NN(input_a, input_b, wa, wb);\n var lose = target - output;\n var error = lose*dactivation(output);\n wa += rate*input_a*error;\n wb += rate*input_b*error;\n}\n\n// 點擊畫面時輸入耳朵長度\u0026尾巴長度\nwhen('click', () =\u003e {\n ia= prompt('輸入耳朵長度')/1\n ib= prompt('輸入尾巴長度')/1\n});\n\n// 按下「空白」按鍵時進行一輪訓練\nwhen('keydown', 'space', () =\u003e {\n for(var i=0;i\u003cdata.length;i++){\n train(data[i][0],data[i][1],data[i][2])\n }\n});\n\n\n\n","created_at":"2019-06-29T16:37:03.613+08:00","updated_at":"2019-11-12T00:36:08.673+08:00","name":"貓咪兔子分類 副本","language":"javascript","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/76527/8dfba7e2b80f63a8a120c85e0fa08620.jpg"},"parent_id":75292,"plugin":"var cat = createSprite('cat.jpeg');\nvar rabbit = createSprite('rabbit.jpg');\ncat.moveTo(500, 100);\ncat.scale = 0.5;\nrabbit.moveTo(500, 380);\nrabbit.scale = 0.5;","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":256,"hashid":"4y3sp95k","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":1325090,"file_name":"rabbit.jpg","project_id":76527,"asset_id":129510,"created_at":"2019-06-29T16:37:03.618+08:00","updated_at":"2019-06-29T16:37:03.618+08:00"},{"id":1325091,"file_name":"cat.jpeg","project_id":76527,"asset_id":129509,"created_at":"2019-06-29T16:37:03.618+08:00","updated_at":"2019-06-29T16:37:03.618+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦