For your reference, a few typical uses are showcased below :
Example 1 :
const options = {
inputs: 1,
outputs: 1,
task: 'regression'
}
const nn = ml5.neuralNetwork(options)
Example 2 : loading data as a csv
const options = {
dataUrl: 'weather.csv',
inputs: ['avg_temperature', 'humidity'],
outputs: ['rained'],
task: 'classification'
}
const nn = ml5.neuralNetwork(options, modelLoaded)
Example 3 : loading data as a json
/**
The weather json looks something like:
{"data": [
{"xs": {"avg_temperature":20, "humidity": 0.2}, "ys": {"rained": "no"}},
{"xs": {"avg_temperature":30, "humidity": 0.9}, "ys": {"rained": "yes"}}
] }
* */
const options = {
dataUrl: 'weather.json',
inputs: ['avg_temperature', 'humidity'],
outputs: ['rained'],
task: 'classification'
}
const nn = ml5.neuralNetwork(options, modelLoaded)
Example 4 : specifying labels for a blank neural network
const options = {
inputs: ['x', 'y'],
outputs: ['label'],
task: 'classification',
};
const nn = ml5.neuralNetwork(options);
Example 5 : creating a convolutional neural network for image classification by setting task: imageClassification
.
const IMAGE_WIDTH = 64;
const IMAGE_HEIGHT = 64;
const IMAGE_CHANNELS = 4;
const options = {
task: 'imageClassification',
inputs:[IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_CHANNELS],
outputs: ['label']
}
const nn = ml5.neuralNetwork(options);