I’m following this tutorial: https://www.youtube.com/watch?v=3MqJzMvHE3E&t=480s on shape classification and I’m encountering the problem
Uncaught Error: Error in oneHot: depth must be >=2, but it is 1
at oneHot_ (tf-core.esm.js:17:357944)
at Object.oneHot (tf-core.esm.js:17:71801)
at NeuralNetworkData.js:560:38
at tf-core.esm.js:17:40461
at t.scopedRun (tf-core.esm.js:17:40603)
at t.tidy (tf-core.esm.js:17:40355)
at Object.rn (tf-core.esm.js:17:67569)
at t.value (NeuralNetworkData.js:550:15)
at NeuralNetworkData.js:533:33
at Array.forEach (<anonymous>)
I’m using ml5.js version 0.6.0 and here is my js file:
const circles = []
function preload() {
for(let i = 0; i < 10; i++) {
let index = nf(i+1, 4, 0);
circles[i] = loadImage(`/data/circle/circle${index}.png`)
}
}
let shapeClassifier;
function setup() {
let options = {
inputs: [128, 128, 4],
task: 'imageClassification',
debug: true
};
shapeClassifier = ml5.neuralNetwork(options);
for (let i = 0; i < circles.length; i++) {
shapeClassifier.addData({ image: circles[i] }, { label: 'circle' });
}
shapeClassifier.normalizeData();
shapeClassifier.train({ epochs: 50 }, () => finishedTraining());
}
function finishedTraining() {
console.log('finished training!');
}
I’m not familiar with ml5 or machine learning in general so I have no idea what this error means or how to fix it, I would really appreciate the help!
I expected it to work and start training the neural network but it didn’t and got this error instead
I expected it to start training the model on the input data but instead got that error