维科纳蒂 »
×
改变方向
在 Codepen 上打开
更改主题,深色/浅色
<!DOCTYPE html> <html> <body> <h1>JavaScript Персептрон</h1> <p>Я піду на концерт?</p> <div id="demo"></div> <script> const threshold = 1.5; const inputs = [1, 0, 1, 0, 1]; const weights = [0.7, 0.6, 0.5, 0.3, 0.4]; let sum = 0; for (let i = 0; i < inputs.length; i++) { sum += inputs[i] * weights[i]; } document.getElementById("demo").innerHTML = (sum > threshold); </script> </body> </html>