Google News
logo
ml5.js - Interview Questions
Defining inputs and output labels as numbers or as arrays of labels in ml5.NeuralNetwork.
Defining inputs and output labels as numbers or as arrays of labels : If you plan to create data in real-time, you can just set the type of task you want to accomplish ('regression' | 'classification') and then create the neuralNetwork. To be more specific about your inputs and outputs, you can also define the names of the labels for your inputs and outputs as arrays OR the number of inputs and outputs. You will have to add data later on. Note that if you add data as JSON, your JSON Keys should match those defined in the options. If you add data as arrays, make sure the order you add your data match those given in the options.
 
As arrays of labels : 
const options = {
  task: 'classification' // or 'regression'
  inputs:['r', 'g','b'],
  outputs: ['color']
}
const nn = ml5.neuralNetwork(options)
 
As numbers :
const options = {
  task: 'classification' // or 'regression'
  inputs: 3, // r, g, b
  outputs: 2 // red-ish, blue-ish
}
const nn = ml5.neuralNetwork(options)
Advertisement