Notion - Update docs

This commit is contained in:
shiffman 2024-03-05 22:38:27 +00:00 committed by GitHub
parent 1812f9f579
commit a61398577b
2 changed files with 2 additions and 2 deletions

View file

@ -583,7 +583,7 @@ for (let i = 1; i < columns - 1; i++) {
// Correct by subtracting the cell state.
neighborSum -= board[i][j];
//{!1} The rules of life!
//{!2} The rules of life!
if (board[i][j] === 1 && neighborSum < 2) next[i][j] = 0;
else if (board[i][j] === 1 && neighborSum > 3) next[i][j] = 0;
//{.continue}

View file

@ -267,7 +267,7 @@ function draw() {
(nextPipe.x - this.x) / width,
];</pre>
</div>
<p>With the inputs in hand, Im ready to pass them to the neural networks <code>classify()</code> method. I have another small problem, however: <code>classify()</code> is asynchronous, meaning Id have to implement a callback inside the <code>Bird</code> class to process the models decision. This would add a significant level of complexity to the code, but luckily, its entirely unnecessary in this case. Asynchronous callbacks with ml5.jss machine learning functions are typically needed because of the time required to process the large amount of data in the model. Without a callback, the code might have to wait a long time to get a result, and if the model is running as part of a p5.js sketch, that delay could severely impact the smoothness of the animation. The neural network here, however, has only four floating-point inputs and two output labels! Its tiny and can run fast enough that theres no reason to use asynchronous code.</p>
<p>With the inputs in hand, Im ready to pass them to the neural networks <code>classify()</code> method. I have another small problem, however: <code>classify()</code> is asynchronous, meaning Id have to implement a callback inside the <code>Bird</code> class to process the models decision. This would add a significant level of complexity to the code, but luckily, its entirely unnecessary in this case. Asynchronous callbacks with ml5.jss machine learning functions are typically needed because of the time required to process the large amount of data in the model. Without a callback, the code might have to wait a long time to get a result, and if the model is running as part of a p5.js sketch, that delay could severely impact the smoothness of the animation. The neural network here, however, has only four floating-point<br>inputs and two output labels! Its tiny and can run fast enough that theres no reason to use asynchronous code.</p>
<div class="avoid-break">
<p>For completeness, I include a version of the example on the books website that implements neuroevolution with asynchronous callbacks. For this discussion, however, Im going to use a feature of ml5.js that allows me to take a shortcut. The method <code>classifySync()</code> is identical to <code>classify()</code>, but it runs synchronously, meaning the code stops and waits for the results before moving on. You should be very careful when using this version of the method as it can cause problems in other contexts, but it will work well for this simple scenario. Heres the end of the <code>think()</code> method with <code>classifySync()</code>:</p>
</div>