Closed lieberscott closed 3 years ago
I have tried to recreate the issue in a p5 web editor dropping in my code to replace Daniel Shiffman's example, and now I'm getting a new error:
tf-core.esm.js:17 Uncaught Error: Cannot infer the missing size in [-1,0] when there are 0 elements
Here's a p5 sketch: https://editor.p5js.org/WSox1235/sketches/aVCCDp7m
Any help greatly appreciated.
I believe the error is coming from the negative and positive values of dob in each object. When I looked at the code in the p5.js web editor. I found that the error is in normalizeData() function. This is what I did to resolve the issue, but yet I couldn't understand what you are trying to achieve with those data, to predict the job of the person using the three properties named male, female and dob??
function mousePressed() {
if (state == 'collection') {
console.log("collecting...");
let total = 0;
for (let person of people_arr) {
total++;
let mappedDob = map(person.dob, -999999999999999,9999999999999999,0,1); // mapping to range 0 and 1
let inputs = {
male: person.male,
female: person.female,
dob: round(abs(mappedDob)) // rounding and converting the values to positive number
}
let target = { label: person.job };
model.addData(inputs, target);
}
console.log("finished collecting total : ", total);
}
else if (state == 'prediction') {
model.classify({ male: 1, female: 0, dob: 0 }, gotResults);
}
}
Hi @lieberscott !
options
: The best thing to do is define your outputs by the output name OR to define outputs:2
-- you have 2 outputs, 0
or 1
..addData
function, you should not use an array but rather just the value that is associated with that data instance e.g.: const input = {
male: person.male,
female: person.female,
dob: person.dob
}
const output = {job: 1}
nn.addData(input, output);
const input = {
sex: person.sex, // 0 or 1
dob: person.dob
}
const output = {job: 1}
nn.addData(input, output);
Hope this helps!
Thanks @joeyklee for the suggested fixes here! Going to go ahead and close this issue for now since it's been quiet for a while, but please feel free to reopen for further discussion.
I am also facing the same issue. Would you please help in solving the issue?
Hi @komal1502 I hope you're well. Based on the screenshots you've provided, it is difficult to diagnose the issue. If it is the case that you're trying to use a model trained in the Teachable Machine, that is unfortunately not supported in the ml5.neuralNetwork function last I checked. If if is the case that you're trying to load a model trained from Teachable Machine, then that might be the issue. Otherwise, without more context, it may be hard to assist you with your error. Thanks!
Sir, Here is my code : https://gitlab.com/k.parulekar152/ai-personaltrainer.git . Could you please look into my problem ? As I am facing an issue in loading custom models such as model.json,model_meta.json and model.weights.bin. Its throwing me an error saying server responded with status 404.
Dear ml5 community,
I am running an ML5 classification using ml5@0.4.3 in a React app, and getting to the
.classify()
step, and when I enter my input into the function, I get an error:Cannot convert undefined or null to object
. I've tried entering the data as both an object{ }
and an array[{ }]
. I can't figure it out.Here is my code
Full error:
TypeError: Cannot convert undefined or null to object at entries (<anonymous>) at index.js:676 at Array.map (<anonymous>) at t.<anonymous> (index.js:668) at x (runtime.js:62) at Generator._invoke (runtime.js:296) at Generator.t.<computed> [as next] (runtime.js:114) at i (asyncToGenerator.js:17) at asyncToGenerator.js:28