Skip to content

Commit

Permalink
Merge pull request #928 from nature-of-code/notion-update-docs
Browse files Browse the repository at this point in the history
fixing illustrations, ml5 cdn change, chapter 6 p5 sketch fix
  • Loading branch information
shiffman committed Apr 2, 2024
2 parents f286509 + 0608553 commit fd14992
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion content/10_nn.html
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ <h2 id="putting-the-network-in-neural-network">Putting the “Network” in Neur
<h2 id="machine-learning-with-ml5js">Machine Learning with ml5.js</h2>
<p>That friend is ml5.js. This machine learning library can manage the details of complex processes like backpropagation so you and I don’t have to worry about them. As I mentioned earlier in the chapter, ml5.js aims to provide a friendly entry point for those who are new to machine learning and neural networks, while still harnessing the power of Google’s TensorFlow.js behind the scenes.</p>
<p>To use ml5.js in a sketch, you must import it via a <code>&#x3C;script></code> element in your <em>index.html</em> file, much as you did with Matter.js and Toxiclibs.js in <a href="/physics-libraries#section-physics-libraries">Chapter 6</a>:</p>
<pre class="codesplit" data-code-language="html">&#x3C;script src="https://unpkg.com/ml5@latest/dist/ml5.min.js">&#x3C;/script></pre>
<pre class="codesplit" data-code-language="html">&#x3C;script src="https://unpkg.com/ml5@1/dist/ml5.min.js">&#x3C;/script></pre>
<p>My goal for the rest of this chapter is to introduce ml5.js by developing a system that can recognize mouse gestures. This will prepare you for <a href="/neuroevolution#section-neuroevolution">Chapter 11</a>, where I’ll add a neural network “brain” to an autonomous steering agent and tie machine learning back into the story of the book. First, however, I’d like to talk more generally through the steps of training a multilayered neural network model using supervised learning. Outlining these steps will highlight important decisions you’ll have to make before developing a learning model, introduce the syntax of the ml5.js library, and provide you with the context you’ll need before training your own machine learning models.</p>
<h3 id="the-machine-learning-life-cycle">The Machine Learning Life Cycle</h3>
<p>The life cycle of a machine learning model is typically broken into seven steps:</p>
Expand Down
76 changes: 38 additions & 38 deletions content/examples/06_libraries/6_5_compound_bodies_error/lollipop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,48 @@ class Lollipop {

// Drawing the lollipop
show() {
// if (mouseIsPressed) {
// // The angle comes from the compound body
// let angle = this.body.angle;
if (mouseIsPressed) {
// The angle comes from the compound body
let angle = this.body.angle;

// //{!2} Get the position for each part
// let position1 = this.part1.position;
// let position2 = this.part2.position;
//{!2} Get the position for each part
let position1 = this.part1.position;
let position2 = this.part2.position;

// fill(127);
// stroke(0);
// strokeWeight(1);
fill(127);
stroke(0);
strokeWeight(1);

// // Translate and rotate the rectangle (part1)
// push();
// translate(position1.x, position1.y);
// rotate(angle);
// rectMode(CENTER);
// rect(0, 0, this.w, this.h);
// pop();
// Translate and rotate the rectangle (part1)
push();
translate(position1.x, position1.y);
rotate(angle);
rectMode(CENTER);
rect(0, 0, this.w, this.h);
pop();

// // Translate and rotate the circle (part2)
// push();
// translate(position2.x, position2.y);
// rotate(angle);
// fill(200);
// circle(0, 0, this.r * 2);
// pop();
// } else {
let position = this.body.position;
let angle = this.body.angle;
rectMode(CENTER);
fill(127);
stroke(0);
strokeWeight(1);
push();
translate(position.x, position.y);
rotate(angle);
rect(0, 0, this.w, this.h);
fill(200);
circle(this.w / 2, 0, this.r * 2);
pop();
// }
// Translate and rotate the circle (part2)
push();
translate(position2.x, position2.y);
rotate(angle);
fill(200);
circle(0, 0, this.r * 2);
pop();
} else {
let position = this.body.position;
let angle = this.body.angle;
rectMode(CENTER);
fill(127);
stroke(0);
strokeWeight(1);
push();
translate(position.x, position.y);
rotate(angle);
rect(0, 0, this.w, this.h);
fill(200);
circle(this.w / 2, 0, this.r * 2);
pop();
}
}

checkEdge() {
Expand Down
Binary file modified content/images/06_libraries/06_libraries_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/images/07_ca/07_ca_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd14992

Please sign in to comment.