Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickstart example for NeuralNetwork not working #154

Open
hansvana opened this issue May 16, 2020 · 2 comments
Open

Quickstart example for NeuralNetwork not working #154

hansvana opened this issue May 16, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@hansvana
Copy link

Tested with @0.4.3 and @0.5.0 (see notes)

Example of the problem: p5js editor

Steps to reproduce:

  • Open a new sketch on the P5js editor (or codepen.io, or local, it didn't matter) with ml5 linked.
  • Copy the Creating data in real-time example from the docs.
  • Run

Problem:

  • The training seems to run, but the visor draws no line in the graph, the result comes out as
0: Object
  red-ish: NaN
  label: "red-ish"
  confidence: NaN
1: Object
  blue-ish: NaN
  label: "blue-ish"
  confidence: NaN

Notes:

  • I did some research. Commenting out line 24 and 25 actually makes the training run. 😄
const inputs = {
    r: item.r, 
    //g: item.g, 
    //b: item.b
};

On @0.5.0 this then also provides a correct prediction. On @0.4.3 the training runs but ends with a high loss and the confidence is NaN.

@joeyklee joeyklee added the bug Something isn't working label May 16, 2020
@joeyklee
Copy link
Contributor

joeyklee commented May 16, 2020

@hansvana - Ahhh I had a look and I think I spot the issue.

If all of the values of g are "0" then the normalization runs into some issues which may be leading to the problem that the training isn't occurring.

const data = [
  {r:255, g:0, b:0, color:'red-ish'},
  {r:254, g:0, b:0, color:'red-ish'},
  {r:253, g:0, b:0, color:'red-ish'},
  {r:0, g:0, b:255, color:'blue-ish'},
  {r:0, g:1, b:254, color:'blue-ish'},
  {r:0, g:1, b:253, color:'blue-ish'},
];

This is definitely a bug that we will need to address. Thanks for surfacing this!

@langfan94
Copy link

@hansvana - Ahhh I had a look and I think I spot the issue.

If all of the values of g are "0" then the normalization runs into some issues which may be leading to the problem that the training isn't occurring.

const data = [
  {r:255, g:0, b:0, color:'red-ish'},
  {r:254, g:0, b:0, color:'red-ish'},
  {r:253, g:0, b:0, color:'red-ish'},
  {r:0, g:0, b:255, color:'blue-ish'},
  {r:0, g:1, b:254, color:'blue-ish'},
  {r:0, g:1, b:253, color:'blue-ish'},
];

This is definitely a bug that we will need to address. Thanks for surfacing this!

ml5js/ml5-library#973 (comment)

If the NN expects a string, I think sholud give a notice, or explicit cast.

pull request to change neural-network.md
#ml5js/ml5-library#1010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants