0
I’m making a neural net with brain.js
, to learn the alphabet. the code is as follows::
const alfabeto = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "Z"];
function converteLetrasemNumeros(letras) {
let alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let codigos = [];
let numeros = [];
for (let i = 0; i < letras.length; i++) {
codigos.push(alfabeto.indexOf(letras[i].toUpperCase()) + 1);
}
numeros.push(codigos);
return numeros;
}
function converteNumerosemLetras(numero) {
let letra;
console.log(String.fromCharCode(numero+64));
return letra;
}
let trainingData = [];
trainingData.push(converteLetrasemNumeros(alfabeto));
const neuralNetwork = new brain.recurrent.LSTMTimeStep({hiddenLayers: [2][3]});
console.log(neuralNetwork.train(trainingData, {errorTrash: 0.0001, iterations: 25000}));
console.log(neuralNetwork.run(converteLetrasemNumeros(["A", "B", "C"])));
<html>
<head>
<script src="https://cdn.rawgit.com/BrainJS/brain.js/45ce6ffc/browser.js"></script>
<script src="index.js"></script>
</head>
<body>
</body>
</html>
The network output, as you can see when executing the code, returns Null
.
Use the answer field for the solution instead of adding in the question
– Bacco