I'm noob at Neural Network implementation, so I'm trying to create a new one but i'm getting this error... Browser error
(我对神经网络实施不了解,所以我尝试创建一个新的,但出现此错误... 浏览器错误)
I was following this article https://www.freecodecamp.org/news/how-to-create-a-neural-network-in-javascript-in-only-30-lines-of-code-343dafc50d49/ step by step, but without success...
(我一直在逐步关注本文https://www.freecodecamp.org/news/how-to-create-a-neural-network-in-javascript-in-only-30-lines-of-code-343dafc50d49/ ,但没有成功...)
Let me show my code, Idk what i'm doing wrong.
(让我展示我的代码,Idk我在做什么错。)
rna_teste.js File(rna_teste.js文件)
var inputLayer = new window.synaptic.Layer(2);
var hiddenLayer = new window.synaptic.Layer(3);
var outputLayer = new window.synaptic.Layer(1);
inputLayer.project(hiddenLayer);
hiddenLayer.project(outputLayer);
var myNetwork = new window.synaptic.Network({
input: inputLayer,
hidden: [hiddenLayer],
output: outputLayer
});
var learningRate = .15;
//pegar o que a pessoa digitar, e contar o tempo que ela leva
//
for (var i = 0; i < 2000000; i++) {
// 0,0 => 0
myNetwork.activate([15,20]);
myNetwork.propagate(learningRate, [0]);
// 0,1 => 1
myNetwork.activate([25,25]);
myNetwork.propagate(learningRate, [0]);
myNetwork.activate([90,10]);
myNetwork.propagate(learningRate, [0]);
myNetwork.activate([80,15]);
myNetwork.propagate(learningRate, [0]);
myNetwork.activate([20,20]);
myNetwork.propagate(learningRate, [0]);
// 0,1 => 1
myNetwork.activate([30,28]);
myNetwork.propagate(learningRate, [0]);
// 1,1 => 0
myNetwork.activate([31,19]);
myNetwork.propagate(learningRate, [0]);
myNetwork.activate([30,18]);
myNetwork.propagate(learningRate, [0]);
// 1,0 => 1
myNetwork.activate([40,35]);
myNetwork.propagate(learningRate, [1]);
// 1,1 => 0
myNetwork.activate([70,60]);
myNetwork.propagate(learningRate, [1]);
myNetwork.activate([60,58]);
myNetwork.propagate(learningRate, [1]);
// 1,1 => 0
myNetwork.activate([65,59]);
myNetwork.propagate(learningRate, [1]);
myNetwork.activate([50,51]);
myNetwork.propagate(learningRate, [1]);
// 1,1 => 0
myNetwork.activate([52,53]);
myNetwork.propagate(learningRate, [1]);
myNetwork.activate([15,90]);
myNetwork.propagate(learningRate, [1]);
myNetwork.activate([80,60]);
myNetwork.propagate(learningRate, [1]);
}
index.html File(index.html文件)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Utilizando o EJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.js"></script>
<script src="rna_teste.js"></script>
</head>
<body>
<form>
<label for="palavra"
>Palavra
<input type="text" id="palavra" />
</label>
<input type="text" id="idade" />
</form>
<button type="button" id="enviar" onclick="iniciarNeuro()">Enviar</button>
<script>
var myNetwork = new window.synaptic.Network();
var tempo = 0;
var primeiro_tempo = true;
var valorPrimeiroTempo = 0;
$("#palavra").keydown(function(event) {
tempo = event.timeStamp.toFixed(2);
console.log(tempo);
if (primeiro_tempo) {
valorPrimeiroTempo = tempo;
primeiro_tempo = false;
console.log("Primeiro tempo" + valorPrimeiroTempo);
}
if (event.which == 13) {
event.preventDefault();
}
});
function temporizador(subtracao) {
var seconds = (subtracao / 1000).toFixed(0);
return seconds;
}
function iniciarNeuro() {
var subtracao = temporizador(tempo - valorPrimeiroTempo);
var idade = $("#idade").val();
console.log(Math.round(myNetwork.activate([idade, subtracao])));
console.log(subtracao);
console.log(tempo - valorPrimeiroTempo);
}
</script>
</body>
</html>
Can anybody help me?
(有谁能够帮助我?)
ask by RAINAN BOMFIM translate from so