CMM-22 / a6

0 stars 0 forks source link

Transcription-app segfaults #4

Open zijhui opened 2 years ago

zijhui commented 2 years ago

For the file transcription-app, segmentation faults will occur once the optimisation button is clicked. In the skeleton code provided, with nothing implemented, will throw segmentation faults. After implementing the objective function, segmentation faults are thrown sometimes, but not always. For example, changing log_c_reg to be a different value in the file will cause segmentation faults.

From my rudimentary investigation, the cause is unknown. It is thrown from the function call at optLib/NewtonFunctionMinimizer.h:21, somewhere deep in nested implementations of Eigen.

MiguelZamoraM commented 2 years ago

When we use the second-order optimizer aka Newton's method, we compute the inverse of the Hessian to find the search direction. The app is probably crashing because the objective that is being optimized is leading to a very ill-conditioned Hessian matrix that cannot be inverted.

Make sure you are not accessing elements beyond the size of the vectors that are used to compute the objective, try to start with simple objectives, and remember to add a sub-objective to enforce physics.

In general, a larger Hessian regularizer (aka a constant that is added to the diagonal of the Hessian) should ease the invertibility of the Hessian matrix.