-
Notifications
You must be signed in to change notification settings - Fork 942
Loss Operations: Adds Absolute Difference loss #775
Conversation
|
Sorry for the delay! Few comments inline. Review status: 0 of 5 files reviewed at latest revision, 10 unresolved discussions. src/ops/loss_ops.ts, line 65 at r1 (raw file):
I know this is what TF says, but they have a Graph model, how about:
src/ops/loss_ops.ts, line 33 at r2 (raw file):
between two tensors src/ops/loss_ops.ts, line 35 at r2 (raw file):
remove ticks around Tensor, we parse the type automatically in the docs src/ops/loss_ops.ts, line 38 at r2 (raw file):
indent these 2 lines 4 more src/ops/loss_ops.ts, line 44 at r2 (raw file):
TF has a default of Reduction.SUM_BY_NONZERO_WEIGHTS, can we keep that as well? src/ops/loss_ops.ts, line 45 at r2 (raw file):
use src/ops/loss_ops.ts, line 46 at r2 (raw file):
instead of doing it like this, can we conditionally do the ".mul" below? We will save a shader call and a texture. src/ops/loss_ops.ts, line 80 at r2 (raw file):
TF has default of SUM_BY_NONZERO_WEIGHTS, can we keep that? src/ops/lossop_tests.ts, line 3 at r2 (raw file):
2018 src/ops/lossop_tests.ts, line 134 at r2 (raw file):
would you mind also testing computeWeightedLoss directly too? Comments from Reviewable |
|
@nsthorat Hi, not a problem :)
I'm not sure if this would be possible considering recent changes. Could you please recheck? Made rest of the changes. |
…/deeplearnjs into add-difference-loss
|
Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion. src/ops/loss_ops.ts, line 61 at r4 (raw file):
qq, in sum by non-zero weights, do we need to do all this? doesn't a multiplication by a weight of 0 do the same thing as manually checking? Comments from Reviewable |
Hi, I'm not sure if I get it. Could you please elaborate more on it? |
|
Left a few comments , but generally looks great! Reviewed 1 of 2 files at r3, 1 of 2 files at r5. src/ops/loss_ops.ts, line 55 at r5 (raw file):
and remove the else { } and un-indent the code in the else. src/ops/loss_ops.ts, line 58 at r5 (raw file):
Make it explicit src/ops/loss_ops.ts, line 59 at r5 (raw file):
can this be simplified to src/ops/loss_ops.ts, line 63 at r5 (raw file):
can this be simplified to: src/ops/lossop_tests.ts, line 1 at r5 (raw file):
rename this file to loss_ops_tests.ts so that the prefix Comments from Reviewable |
|
@dsmilkov Addressed the comments |
|
Reviewed 1 of 6 files at r6. src/ops/loss_ops.ts, line 48 at r6 (raw file):
Keep weights null and check for their value inside the if statements so we can save shader calls and improve numerical stability. see comments below. src/ops/loss_ops.ts, line 51 at r6 (raw file):
we can save a shader call if we check that weights are null here , that is: src/ops/loss_ops.ts, line 52 at r6 (raw file):
Remove this loss variable. See comments below. src/ops/loss_ops.ts, line 57 at r6 (raw file):
Dont' precompute the sum of weightedLoss, since we won't use it in the Reduction.MEAN case. Do it inside the if statement. That is: src/ops/loss_ops.ts, line 62 at r6 (raw file):
note we want mean() directly, since it avoids the potential overflow that x.sum().div(n) has. Also note we call weightedLoss.sum(), since the temp src/ops/loss_ops.ts, line 65 at r6 (raw file):
weightedLoss.sum().div(numNonZeros) src/ops/lossop_tests.ts, line 1 at r5 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
My appologies for the typo: the filename must end with test.ts not tests.ts for the actual test runner to pick it up. Comments from Reviewable |
|
Thanks. Took another pass. There is a couple of small improvements we can do regarding perf and numerical stability, but this looks great already! |
|
@dsmilkov In Tensorflow defaults to 1 in this case. Also, Typescript is complaining about not returning anything at the end. Should we return |
|
When Regarding Typescript, throw an |
|
@dsmilkov I had thought about throwing an error but then I realized error will automatically be thrown if anything other than Made the required changes. :) |
|
Review status: 1 of 4 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. Comments from Reviewable |
|
Hi Manraj, Few tests are failing when I synced to master (see log). Nothing major, I think it's related to the fact that we made |
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
This PR adds absolute difference loss to the api.
This change is