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

tf.computeWeightedLoss should apply broadcast before reduction #466

Closed
manrajgrover opened this issue Jun 25, 2018 · 1 comment
Closed

Comments

@manrajgrover
Copy link
Contributor

manrajgrover commented Jun 25, 2018

To get help from the community, check out our Google group.

TensorFlow.js version

0.11.9

Browser version

Version 67.0.3396.87 (Official Build) (64-bit)

Describe the problem or feature request

tf.computeWeightedLoss currently does not apply broadcast on weights on reduction SUM_BY_NONZERO_WEIGHTS before calculating non-zero values. This leads to wrong output. See tensorflow implementation. Found it while working on tensorflow/tfjs-core#1120

Code to reproduce the bug / link to feature request

const losses = tf.tensor2d([[0, 0, 1], [1, 0, 0], [0, 1, 0]], [3, 3]);
const weights = tf.tensor2d([[0.1, 0.2, 0.3]]);

tf.losses.computeWeightedLoss(losses, weights).print();
// Tensor
//    0.20000001788139343 (should be 0.06666667014360428)
@manrajgrover
Copy link
Contributor Author

I can take this one up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant