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
Tickets/DM-13806 #53
Tickets/DM-13806 #53
Conversation
using Moments = Eigen::Matrix<double, 6, 1>; | ||
using Jacobian = Eigen::Matrix<double, 6, 6>; | ||
using FirstMoment = Eigen::Matrix<double, 2, 1>; | ||
using SecondMoment = Eigen::Matrix<double, 2, 2>; |
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 may want to add using Element = double;
and then parameterize the rest on it.
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.
Done
* maximally likely image moments given moments measured from an image. As such the class | ||
* provides two methods in addition to the at method already mentioned. One method computes the | ||
* biased weighted moments given the specified weight and "true" moments, and the other computes | ||
* the derivative of the objective function along each of the image moment variables. |
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.
Maybe not start every sentence with "This class".
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.
Made this easier to read
* moments intrinsic to an object, and a vector of moments representing a weighting function. | ||
* | ||
* The class is constructed with the moments of weight function, and the moments of the object | ||
* are set by calling the at method. This allows a single instance to be reused to evaluate |
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.
See later comments about at
.
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.
switched name to setParameters
* The class is constructed with the moments of weight function, and the moments of the object | ||
* are set by calling the at method. This allows a single instance to be reused to evaluate | ||
* multiple positions in object moment space. This structure is computationally more efficient | ||
* as well since the weight function would remain constant for many evaluation of image moments |
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.
evaluations?
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.
changed
* a normalized weight function. | ||
*/ | ||
MomentsModel(Moments const & W): W(W) { | ||
} |
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.
Please also explicitly default
or delete
copy/move constructors / assignment operators and destructor.
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.
done
src/RegularizedMoments.cc
Outdated
// Calculates and returns the derivatives for the alpha components. | ||
auto makeAlphaGrad(Moments const & Q, Moments const & W) { | ||
double muBottom, sigBottom; | ||
std::tie(muBottom, sigBottom) = makeAlphaGradDivisors(Q, W); |
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'd love some structured bindings ;)
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.
me too
src/RegularizedMoments.cc
Outdated
if (abs(zeroTruth - zeroRes) > tol) { | ||
return false; | ||
} | ||
return approxEqual(firstRes, firstTruth, tol); |
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.
return (abs(zeroTruth - zeroRes) < tol) && approxEqual(firstRes, firstTruth, tol)
? Or move the first test higher to prevent the assignment cost? Or just leave these as they are, since they are minor tests anyway.
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.
not worth worrying about in the test that will get called a small number of time, and with small length vectors
return false; | ||
} | ||
return approxEqual(firstRes, firstTruth, tol); | ||
} |
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.
Again, i'd move all these tests out of here. Since they obscure the implementation of the class.
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.
discussed above
src/RegularizedMoments.cc
Outdated
|
||
// Sets the location in moment space to evaluate | ||
void MomentsModel::at(Moments const & inputQ) { | ||
Q = Moments(inputQ); |
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.
Why not just assign?
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.
changed
src/RegularizedMoments.cc
Outdated
// Returns the value of the weighted biased moments calculation | ||
Moments MomentsModel::computeValues() { | ||
return value; | ||
} |
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 doesn't compute anything. Also why is value
singular and computeValues
plural? Perhaps getValue
would be better?
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.
change value to plural. Also this signature was chosen so in the future someone my substitute a different objective function where the work may be done in the computeValues function, and the api will stay the same
Add a class which functions as an objective functional model of biased weighted moments and its derivatives given input moments and weights. This is intended to be used in conjunction with an optimizer to find the moments which maximize the likelyhood of moments given input measurements from data.
No description provided.