Skip to content

Commit 4f3ba03

Browse files
committed
nature of code examples update
1 parent c31ecf4 commit 4f3ba03

46 files changed

Lines changed: 15 additions & 1676 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

java/examples/Books/Nature of Code/chp10_nn/LayeredNetworkViz/sketch.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/examples/Books/Nature of Code/chp10_nn/NOC_10_03_NetworkViz/sketch.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/examples/Books/Nature of Code/chp10_nn/NOC_10_04_NetworkAnimation/sketch.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

java/examples/Books/Nature of Code/chp10_nn/xor/xor.pde

100755100644
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Neural network code is all in the "code" folder
77

88
import nn.*;
9-
import java.text.DecimalFormat;
109

1110
ArrayList inputs; // List of training input values
1211
Network nn; // Neural Network Object
@@ -30,17 +29,17 @@ void setup() {
3029
// Create a list of 4 training inputs
3130
inputs = new ArrayList();
3231
float[] input = new float[2];
33-
input[0] = 1;
34-
input[1] = 0;
32+
input[0] = 1;
33+
input[1] = 0;
3534
inputs.add((float []) input.clone());
36-
input[0] = 0;
37-
input[1] = 1;
35+
input[0] = 0;
36+
input[1] = 1;
3837
inputs.add((float []) input.clone());
39-
input[0] = 1;
40-
input[1] = 1;
38+
input[0] = 1;
39+
input[1] = 1;
4140
inputs.add((float []) input.clone());
42-
input[0] = 0;
43-
input[1] = 0;
41+
input[0] = 0;
42+
input[1] = 0;
4443
inputs.add((float []) input.clone());
4544
}
4645

@@ -52,7 +51,7 @@ void draw() {
5251
// Pick a random training input
5352
int pick = int(random(inputs.size()));
5453
// Grab that input
55-
float[] inp = (float[]) inputs.get(pick);
54+
float[] inp = (float[]) inputs.get(pick);
5655
// Compute XOR
5756
float known = 1;
5857
if ((inp[0] == 1.0 && inp[1] == 1.0) || (inp[0] == 0 && inp[1] == 0)) known = 0;
@@ -78,7 +77,7 @@ void draw() {
7877
// Draw the landscape
7978
popMatrix();
8079
land.calculate(nn);
81-
land.render();
80+
land.render();
8281
theta += 0.0025;
8382
popMatrix();
8483

@@ -97,7 +96,7 @@ void networkStatus() {
9796
text("Total iterations: " + count,10,40);
9897

9998
for (int i = 0; i < inputs.size(); i++) {
100-
float[] inp = (float[]) inputs.get(i);
99+
float[] inp = (float[]) inputs.get(i);
101100
float known = 1;
102101
if ((inp[0] == 1.0 && inp[1] == 1.0) || (inp[0] == 0 && inp[1] == 0)) known = 0;
103102
float result = nn.feedForward(inp);
@@ -106,8 +105,7 @@ void networkStatus() {
106105
}
107106

108107
float rmse = sqrt(mse/4.0);
109-
DecimalFormat df = new DecimalFormat("0.000");
110-
text("Root mean squared error: " + df.format(rmse), 10,60);
108+
text("Root mean squared error: " + nf(rmse,1,5), 10,60);
111109

112110
}
113111

java/examples/Books/Nature of Code/chp2_forces/NOC_02forces_many_attraction_3D/sketch.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/examples/Books/Nature of Code/chp2_forces/NOC_02forces_many_mutual_boundaries/sketch.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/examples/Books/Nature of Code/chp4_systems/NOC_4_04_SystemofSystems/NOC_4_04_SystemofSystems.pde

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ void draw() {
2121
ps.run();
2222
ps.addParticle();
2323
}
24+
25+
fill(0);
26+
text("click mouse to add particle systems",10,height-30);
2427
}
2528

2629
void mousePressed() {

java/examples/Books/Nature of Code/chp4_systems/NOC_4_04_SystemofSystems_b/NOC_4_04_SystemofSystems_b.pde

Lines changed: 0 additions & 35 deletions
This file was deleted.

java/examples/Books/Nature of Code/chp4_systems/NOC_4_04_SystemofSystems_b/Particle.pde

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)