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

Issue with Dynamic Theta Update in Graduated Non-Convexity for Ceres Solver #25

Open
arenas7307979 opened this issue Jun 28, 2024 · 0 comments

Comments

@arenas7307979
Copy link

arenas7307979 commented Jun 28, 2024

I am working on implementing the Geman-McClure loss function with a dynamic update of the theta parameter in each iteration to achieve Graduated Non-Convexity (GNC) results in the Ceres Solver. Despite following the recommended approach, my current implementation does not seem to influence the Ceres solver's behavior as expected. I would greatly appreciate your guidance on this matter. Below is a rough outline of my code:

// Geman-McClure
else if (loss == "Geman"){
double a =2;
loss_function = new GemanMcClureLoss(a);
}

// Geman-McClure loss function class
class GemanMcClureLoss : public ceres::LossFunction
{
public:
explicit GemanMcClureLoss(double delta) : delta_(delta), delta_square(delta * delta) {}

virtual void Evaluate(double s, double rho[3]) const override
{
    const double aux = 1.0 / (delta_ + s);

    rho[0] = delta_ * s * aux;
    rho[1] = delta_square * aux * aux;
    rho[2] = -2. * rho[1] * aux;
}

private:
const double delta_;
const double delta_square;
};

// Main loop for iterating and updating theta
int max_iter = 5;

for (int iter = 0; iter < max_iter; ++iter) {
ceres::Problem problem;

// Add residual blocks with Geman-McClure loss
ceres::CostFunction* cost_function = new ceres::AutoDiffCostFunction<ResidualFunction, 1, 1>(new ResidualFunction(res));
problem.AddResidualBlock(cost_function, loss_function, &initial_x);

// Solver configuration and solving
ceres::Solver::Options options;
ceres::Solver::Summary summary;
ceres::Solve(options, &problem, &summary);

// Update theta value and reset the loss function's theta
theta /= 1.4;
loss_function->UpdateTheta(theta);
}

@arenas7307979 arenas7307979 changed the title Issue with Dynamic Theta Update in Geman-McClure Loss Function for Ceres Solver Issue with Dynamic Theta Update in Graduated Non-Convexity for Ceres Solver Jun 28, 2024
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