Skip to content

Weird bug with brain.js #948

Open
@DrFrankxio

Description

@DrFrankxio

The error is this:

brain-browser.js:41191 Uncaught TypeError: Cannot read properties of null (reading 'equations')
at LSTM.get (brain-browser.js:41191:22)
at LSTM.run (brain-browser.js:40778:17)
at perceptron.html:37:16

And my code is this:

<script src="https://cdnjs.cloudflare.com/ajax/libs/brain.js/2.0.0-beta.1/brain-browser.js" integrity="sha512-bI0AOBSlsQUR/VlZhVj6PuYqjQFO4YTD6Fpw2UBEGC+QkZWLiDgiFZpDefJFnS+ptTjiwZS30VsaF5vJtkQCGw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

[0,0]=><input id="t1"value="1">=>Result:[0,0]=>

[0,1]=><input id="t2"value="1">=>Result:[0,1]=>

[1,0]=><input id="t3"value="1">=>Result:[1,0]=>

[1,1]=><input id="t4"value="1">=>Result:[1,1]=>

<script> const net = new brain.recurrent.LSTM({ inputSize: 2, hiddenLayers: [ { size: 4 }, { size: 2 } ], outputSize: 1 }); render = () => { net.train( [ { input: [0, 0], output: [parseFloat(t1)] }, { input: [0, 1], output: [parseFloat(t2)] }, { input: [1, 0], output: [parseFloat(t3)] }, { input: [1, 1], output: [parseFloat(t4)] }, ], { iterations: 100, // Reducir iteraciones para mayor velocidad log: true, logPeriod: 100, errorThresh: 0.005, } ); isTrained = true; status.textContent = "Training complete!"; updateResults(); } // Permitir al navegador procesar mientras entrena r1.value = net.run({input: [0, 0]}); r2.value = net.run({input: [0, 1]}); r3.value = net.run({input: [1, 0]}); r4.value = net.run({input: [1, 1]}); requestAnimationFrame(render) render() </script>

So, i want all inputs get the same value at each row.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions