Skip to content

Commit 76a5eed

Browse files
authored
Update NeuralNetwork docs (#631)
* skeleton of generic Neural Network * proof of concept for training and prediction * use ml5 callcallbac to handle callback or promisek * added activation to options * load save model * adds placeholder to test and adds defaults * DIY Neural Net Updates (#568) * begins restructuring * adds tfjs-vis and adds generic createModel() function * adds tf viz and adds loadData function * adds normalization function * adds train function * adds predict function * work on DIY Neural Network (#569) * fixing output and hidden activations * moving data fields config to loadData() Eventually this should be ml5.utils() or ml5.data() * trimming whitespace * rename labels to targets for training output * using camelCase * moves shuffle out of normalize * [WIP] DIY Neural Net with focus on handling data internally (#571) * adds data obj in class * adds initialization step * creates nn data class * moves functions to data class * working with titanic * adds tf vis for training * changes tf viz show on training is debug is true * changes optimizer for regression * adds unNormalize function * fix normalization * rm log * refactors out to sep modules * adds options to train * adds options to train * adds comments * adds input/output array function * removes i/o label check * fixes optionOrCallback * fix test * adds comments * updates data handling * updates normalization data handling * DIY NN data handling updates (#572) * set up scaffold for creating inputs * added output scaffolding - turn into functions todo * adds function to encode data with ontHot or not * ensure inputTypes/outputTypes exist * [In progress] DIY NN - handles json and csv loading (#573) * adds placeholders for json and csv loader' * add json parsing * adds true flag to normalization to fix broken function * Fixes normalization function for NN (#575) * adds possible fix - moves norm to external function * adds correctly ordered data * DIY Neural Network: Handles onehot() encoding for inputs and outputs in normalization (#576) * adds correct input structure - accounts for onehot inputs * code formatting and cleaning * fixes need for onehot in classification for numeric output * adds whileTraining cb support to train (#577) * regression needs to pickup learning rate * Adds temporary fixes for i/o values given to/output by .predict() (#578) * adds min and max to meta and checks predict sample and forces array * adds onehot encoding legend * updating input handling for predict() * adds label,confidence output for classification * fix merge conflicts * rm log * need to use inputUnits and not input length * [WIP] Fixes for before class (#581) * changes for class * values not value, but this does not match feature extractor regression * [Diy nn] Fixes output reversal and gives unnormalized data as outputs of predict() (#582) * unnormalize outputs for regression * use .reverse() - note: we should use .unshift() where order matters * code cleanup * updates config inputs learning rate and code cleanup * changed value to return result.outputs * adds blob reader for json * [diy nn] moves tf-vis visualizations to helper class (#583) * adds tfvis to neuralNetworkVis.js * adds tfvis to class * handle text and convert to json (#584) * allow user more control in the case of classification * allow user more control in the case of classification (#585) * Refactoring DIY Neural Network (#591) * [wip] refactoring data handling and logic separation * wip adding convertRawToTensor * adds conversion to tensor * adds normalization step * adds train() * adds predictInternal() * fixes unique value mapping issue * comment out .print() * return all regression results * adds experimental normalizationOptions object * quick fix for checking if normalizationOptions exists * commenting out auto tensor printing * adds checks for normalizationOptions * fix obj ref in conditional * adds .normalizeData() - keeps .normalize() for now * changes whileTraining function when debug is true * adds layer options for adding more than 2 layers - experimentalgit add . * remove .normalize() in favor of .normalizeData() * adds save() and load() * adds data.warmUp() to allow training without normalization - handled internally on train * updates outputs of .predict() and .classify() to be array * Divide by 0 issue when data is not normalized (#596) * skipping calculating inputMin and inputMax when data not normalized * adds check for this.data.meta.isNormalized in predictInternal * Diy nn code cleanup (#606) * adds input/output checks to specify number or array of input/output names * moves model creation to training to compile after input and output units have been calcd * cleanup code in .trainInternal() * move vars up to top of function in .trainInternal() * rm model creation from .createModelFromDataInternal() * code cleanup and adds comments to .initializeIOUnits() * code cleanup * [DIY NN] Adds .saveData() and .loadData() (#607) * adds saveData function * updates saveData() with input checks * adds loadData function * [Diy NN] Adds .predictMultiple() for batch predictions/classifications (#609) * adds predictMultiple() * rm ys.print() * moves bodypix and faceapi to preload support to match base branch * [DIY nn] Neural Net Fixes loading pre-trained model (#613) * adds model_meta.json to savedfiles * adds loading of model_meta.json - temp fix * use substring method for url checking * adds check for if input is JSON * loadData and text variables mixed up (#615) * updates docs on loading model and adds contributors * updates neural network docs with .load docs * fix paths in examples * adds nn src and adds placeholder
1 parent ef0aabb commit 76a5eed

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

docs/reference/neural-network.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,20 @@ neuralNetwork.load(?filesOrPath, ?callback)
408408
* **filesOrPath**: REQUIRED. String | InputFiles.
409409
* If a string path to the `model.json` data object is given, then the `model.json`, `model_meta.json` file and its accompanying `model.weights.bin` file will be loaded. Note that the names must match.
410410
* If InputFiles from html input `type="file"`. Then make sure to select ALL THREE of the `model.json`, `model_meta.json` and the `model.weights.bin` file together to upload otherwise the load will throw an error.
411+
* Method 1: using a json object. In this case, the paths to the specific files are set directly.
412+
```js
413+
const modelInfo = {
414+
model: 'path/to/model.json',
415+
metadata: 'path/to/model_meta.json',
416+
weights: 'path/to/model.weights.bin'
417+
}
418+
neuralNetwork.load(modelInfo, modelLoadedCallback)
419+
```
420+
* Method 2: specifying only the path to th model.json. In this case, the `model_meta.json` and the `model.weights.bin` are assumed to be in the same directory, named exactly like `model_meta.json` and `model.weights.bin`.
421+
```js
422+
neuralNetwork.load('path/to/model.json', modelLoadedCallback)
423+
```
424+
* Method 3: using the `<input type="file" multiple>`
411425
* **callback**: Optional. function. A callback that is called after the model has been loaded.
412426
413427
📤 **Outputs**
@@ -422,17 +436,28 @@ neuralNetwork.load(?filesOrPath, ?callback)
422436
## Examples
423437
424438
**plain javascript**
425-
* [Example 1]()
426-
* [Example 2]()
427439
440+
* coming soon
428441
429442
**p5.js**
430-
* [Example 1]()
431-
* [Example 2]()
443+
- [NeuralNetwork_Simple-Classification](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification)
444+
- [NeuralNetwork_Simple-Regression](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_Simple-Regression)
445+
- [NeuralNetwork_XOR](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_XOR)
446+
- [NeuralNetwork_basics](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_basics)
447+
- [NeuralNetwork_co2net](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_co2net)
448+
- [NeuralNetwork_color_classifier](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_color_classifier)
449+
- [NeuralNetwork_load_model](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_load_model)
450+
- [NeuralNetwork_load_saved_data](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_load_saved_data)
451+
- [NeuralNetwork_lowres_pixels](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels)
452+
- [NeuralNetwork_multiple-layers](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_multiple-layer)
453+
- [NeuralNetwork_musical_face](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_musical_face)
454+
- [NeuralNetwork_musical_mouse](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_musical_mouse)
455+
- [NeuralNetwork_pose_classifier](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_pose_classifier)
456+
- [NeuralNetwork_titanic](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_titanic)
457+
- [NeuralNetwork_xy_classifier](https://github.com/ml5js/ml5-examples/tree/development/p5js/NeuralNetwork/NeuralNetwork_xy_classifier)
432458
433459
**p5 web editor**
434-
* [Example 1]()
435-
* [Example 2]()
460+
* coming soon
436461
437462
## Demo
438463
@@ -455,6 +480,6 @@ No tutorials yet - contribute one today!
455480
456481
## Source Code
457482
458-
* [/src/MagicFeature]()
483+
* [/src/NeuralNetwork](https://github.com/ml5js/ml5-library/tree/development/src/NeuralNetwork)
459484
460485

0 commit comments

Comments
 (0)