Skip to content

Commit d295a87

Browse files
2 parents 1a60302 + a4c9fff commit d295a87

File tree

10 files changed

+12548
-11721
lines changed

10 files changed

+12548
-11721
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
+ [Initialization](#initialization)
3333
+ [Transform](#transform)
3434
- [Utilities](#utilities)
35-
+ [`likely`](#-likely-)
35+
+ [`likely`](#likely)
3636
- [Neural Network Types](#neural-network-types)
37-
+ [Why different Neural Network Types?](#why-different-neural-network-types-)
37+
+ [Why different Neural Network Types?](#why-different-neural-network-types)
3838

3939
# Examples
4040
Here's an example showcasing how to approximate the XOR function using `brain.js`:
@@ -129,15 +129,16 @@ var output = net.run({ r: 1, g: 0.4, b: 0 }); // { white: 0.81, black: 0.18 }
129129

130130
```javascript
131131
net.train(data, {
132-
iterations: 20000, // the maximum times to iterate the training data
133-
errorThresh: 0.005, // the acceptable error percentage from training data
134-
log: false, // true to use console.log, when a function is supplied it is used
135-
logPeriod: 10, // iterations between logging out
136-
learningRate: 0.3, // scales with delta to effect traiing rate
137-
momentum: 0.1, // scales with next layer's change value
138-
callback: null, // a periodic call back that can be triggered while training
139-
callbackPeriod: 10, // the number of iterations through the training data between callback calls
140-
timeout: Infinity // the max number of milliseconds to train for
132+
// Defaults values --> expected validation
133+
iterations: 20000, // the maximum times to iterate the training data --> number greater than 0
134+
errorThresh: 0.005, // the acceptable error percentage from training data --> number between 0 and 1
135+
log: false, // true to use console.log, when a function is supplied it is used --> Either true or a function
136+
logPeriod: 10, // iterations between logging out --> number greater than 0
137+
learningRate: 0.3, // scales with delta to effect traiing rate --> number between 0 and 1
138+
momentum: 0.1, // scales with next layer's change value --> number between 0 and 1
139+
callback: null, // a periodic call back that can be triggered while training --> null or function
140+
callbackPeriod: 10, // the number of iterations through the training data between callback calls --> number greater than 0
141+
timeout: Infinity // the max number of milliseconds to train for --> number greater than 0
141142
});
142143
```
143144

@@ -151,6 +152,8 @@ The momentum is similar to learning rate, expecting a value from `0` to `1` as w
151152

152153
Any of these training options can be passed into the constructor or passed into the `updateTrainingOptions(opts)` method and they will be saved on the network and used any time you trian. If you save your network to json, these training options are saved and restored as well (except for callback and log, callback will be forgoten and log will be restored using console.log).
153154

155+
There is a boolean property called `invalidTrainOptsShouldThrow` that by default is set to true. While true if you enter a training option that is outside the normal range an error will be thrown with a message about the option you sent. When set to false no error is sent but a message is still sent to `console.warn` with the information.
156+
154157
### Async Training
155158
`trainAsync()` takes the same arguments as train (data and options). Instead of returning the results object from training it returns a promise that when resolved will return the training results object.
156159

0 commit comments

Comments
 (0)