You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35Lines changed: 35 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@
18
18
+[Browser](#browser)
19
19
-[Training](#training)
20
20
+[Data format](#data-format)
21
+
+[For training with NeuralNetwork](#For-training-with-NeuralNetwork)
21
22
+[Training Options](#training-options)
22
23
+[Async Training](#async-training)
23
24
-[Methods](#methods)
@@ -104,6 +105,7 @@ Use `train()` to train the network with an array of training data. The network h
104
105
at classifying new patterns.
105
106
106
107
### Data format
108
+
#### For training with `NeuralNetwork`
107
109
Each training pattern should have an `input` and an `output`, both of which can be either an array of numbers from `0` to `1` or a hash of numbers from `0` to `1`. For the [color contrast demo](https://brain.js.org/) it looks something like this:
* Either of which can an array of values or a string
134
+
135
+
CAUTION: When using an array of values, you can use ANY value, however, the values are represented in the neural network by a single input. So the more _distinct values_ has _the larger your input layer_. If you have a hundreds, thousands, or millions of floating point values _THIS IS NOT THE RIGHT CLASS FOR THE JOB_. Also, when deviating from strings, this gets into beta
136
+
137
+
Example using direct strings:
138
+
```javascript
139
+
var net =newbrain.NeuralNetwork();
140
+
141
+
net.train([
142
+
'doe, a deer, a female deer',
143
+
'ray, a drop of golden sun',
144
+
'me, a name I call myself',
145
+
]);
146
+
147
+
var output =net.run('doe'); // ', a deer, a female deer'
148
+
```
149
+
150
+
Example using strings with inputs and outputs:
151
+
```javascript
152
+
var net =newbrain.NeuralNetwork();
153
+
154
+
net.train([
155
+
{ input:'I feel great about the world!', output:'happy' },
156
+
{ input:'The world is a terrible place!', output:'sad' },
157
+
]);
158
+
159
+
var output =net.run('I feel great about the world!'); // 'happy'
0 commit comments