Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird bug with brain.js #948

Open
DrFrankxio opened this issue Dec 30, 2024 · 0 comments · May be fixed by #952
Open

Weird bug with brain.js #948

DrFrankxio opened this issue Dec 30, 2024 · 0 comments · May be fixed by #952
Labels

Comments

@DrFrankxio
Copy link

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.

@DrFrankxio DrFrankxio added the bug label Dec 30, 2024
rizmyabdulla added a commit to rizmyabdulla/brain.js that referenced this issue Jan 18, 2025
Fixes BrainJS#948

Initialize the `equations` property in the `LSTM` class constructor in `src/recurrent/lstm.ts`.

* Ensure the `equations` property is properly populated before it is accessed in the `get` method of the `LSTM` class.
* Initialize the `equations` property in the `LSTMTimeStep` class constructor in `src/recurrent/lstm-time-step.ts`.
* Ensure the `equations` property is properly populated before it is accessed in the `getEquation` method of the `LSTMTimeStep` class.
* Add test cases in `src/recurrent/lstm-time-step.test.ts` to verify that the `equations` property is properly initialized and populated.
* Add end-to-end test cases in `src/recurrent/lstm-time-step.end-to-end.test.ts` to verify that the LSTM model correctly trains and produces the expected output values.
@rizmyabdulla rizmyabdulla linked a pull request Jan 18, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant