-
Notifications
You must be signed in to change notification settings - Fork 767
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
Make mEstimator variable names consistent with math #188
Make mEstimator variable names consistent with math #188
Conversation
Rename mEstimator residual to loss so that it is not confused with lsq residual vector Ax-b. Rename distance to squaredDistance when appropriate. Removed erroneous 0.5 factor from NoiseModelFactor::weight() Fix bug in mEstimator::Null::loss()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelbosse: The filename LossFunctions.*
is very generic and obscure. Could we change it to MEstimators.*
?
Reviewable status: 0 of 8 files reviewed, all discussions resolved
@@ -106,7 +106,7 @@ double NoiseModelFactor::weight(const Values& c) const { | |||
if (noiseModel_) { | |||
const Vector b = unwhitenedError(c); | |||
check(noiseModel_, b.size()); | |||
return 0.5 * noiseModel_->weight(b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might cause regressions. 🙁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is very significant, and seems fishy. Too bad this stuff did not get resolved when it was fresh in our minds, but now we have to re-argue this, and why it was not in @yetongumich PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I believe the 0.5
should NOT be present, since if the noiseModel_
is not robust, the weight function should simply be 1 (which in NoiseModel.h it is). If the noise model is robust, then it should just return the weight value for that particular M-estimator given the residuals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, there isn't any test for this 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, there isn't any reasonable usages for this function either...
Also, I think the 0.5 factor should not be there. @dellaert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only usage of this function is in gtsam_unstable/partition
, so I suggest this function to be moved to unstable as a standalone function there.
Plus, this change is correct.
@ProfFan and @yetongumich are currently examining/fixing all issues wrpt to Robust errors. We will get to this branch in due time but for now let's keep it dormant. |
This reverts commit 4e3542a.
This reverts commit 4e3542a.
@mikebosse you probably have given up on this, but we merged a very similar PR yesterday based on this PR (and a lot of conversation about robust models). If you have a minute please merge in develop and see what still remains? You might have to fix some conflicts, please resolve in favor of "distance". |
Hi @mikebosse , In PR #269 , we have incorporated your changes by renaming residual to loss. In addition, we have also deprecated the "distance" function, and create mahalanobisDistance and squaredMahalanobisDistance, so that the code can better agree with math. |
@yetongumich Please create a branch off of this branch and resolve conflicts with develop, then close this Pr and submit other branch? I would like to see what was in this PR that we have not yet done in your PR, inspired by this one. Probably nothing, but let’s be sure and clean this up. |
@dellaert I think this PR merges directly into develop. May I know if we still need to create a new branch off this one? As I went through "Files Changed" of this PR, the changes include
All the changes should be already incorporated in the current develop branch. |
@yetongumich it too more energy to reply above than it takes to create the PR :-) |
I went ahead and synced the fork so we can easily check what is left. Moreover, I also uncommented and fixed some tests which should work given the updates to the robust losses. |
@dellaert @yetongumich looks like you guys got everything! 🎉 Can I get a review so we can (finally) merge this in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to update me on this one...
I just merged in the latest @michaelbosse's PR pretty much covered exactly the changes you, @yetongumich and @ProfFan had made previously. I saw that the changes were minimal so I pushed them up to this PR. |
@@ -101,6 +101,82 @@ TEST( NonlinearFactor, NonlinearFactor ) | |||
DOUBLES_EQUAL(expected,actual,0.00000001); | |||
} | |||
|
|||
/* ************************************************************************* */ | |||
TEST(NonlinearFactor, Weight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yetongumich and @ProfFan
You guys did the deep dive into robust models. Can you please weigh in?
@ProfFan @yetongumich "I see no problem" will not cut it :-) You guys did a deep dive into this a while ago, and should be able to decisively argue whether the 0.5 factor should be there, or not there. In either case, it will need a justification. |
Can we get this merged in soon please? 🙂 |
@ProfFan @yetongumich let's get this one in? |
@yetongumich Could you take a look at this? We need this one for 4.1 release. |
Sorry for the late response. I went through this PR again, and we should be good with merging. |
We still need a justification. 🙂 |
Whatever the outcome is, it should be documented somewhere so we don’t have to go through this again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The weight
function is not used anywhere other than gtsam_unstable
, is untested, so I suggest it either be removed or moved to unstable as a standalone function. We can also merge this PR as-is. @dellaert
@dellaert @yetongumich @varunagrawal I am merging this if there are no objections. The weight in NoiseModelFactor should be the same as the one in the robust noise model. |
Yeah go for it. I don't know why @yetongumich isn't responding but we can't have him delay progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We need @dellaert to approve |
@yetongumich needs to look at this. Please talk to him on slack/chat/whatever. |
@@ -101,6 +101,82 @@ TEST( NonlinearFactor, NonlinearFactor ) | |||
DOUBLES_EQUAL(expected,actual,0.00000001); | |||
} | |||
|
|||
/* ************************************************************************* */ | |||
TEST(NonlinearFactor, Weight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@yetongumich you need to provide the answers for the above questions that Frank posed. This PR is basically waiting on you. 🙂 |
Agreed! |
Justification for why we should remove the 0.5: The behavior of "weight" function in NoiseModelFactor should be the same as the "weight" function in NoiseModels. In robust NoiseModel, weights will change by values throughout iterations, while for gaussian NoiseModel, weight shall just stay 1. Therefore, the "weight" function should return the weight of the noisemodel, and should not have the 0.5 multiplier. Another justification is that when there's no noisemodel, the weight is 1, which is the same weight as Gaussian noise. I don't know why there is a multiplier of 0.5 in the old code, maybe because of copy-paste from the |
@dellaert I agree with @yetongumich 's answer |
@dellaert We need your approval to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phew, this took a while (Yetong!) but let's finally land.
Rename mEstimator residual to loss so that it is not confused
with lsq residual vector Ax-b.
Rename distance to squaredDistance when appropriate.
Removed erroneous 0.5 factor from NoiseModelFactor::weight()
Fix bug in
mEstimator::Null::loss()
This change is