Open azzabenfarhat opened 2 years ago
I don't have enough information to go off of. The example https://github.com/Edwinem/ceres_python_bindings/blob/master/examples/ceres_hello_world_analytic_diff.py works on my computer so I would say try to copy that as much as possible.
Some potential problems I can think of:
Maybe something like this?
np_arr_to_optimize = np.array( [0.5])
problem = PyCeres.Problem()
for a in list:
np_arr_to_optimize = np.array( [a.val])
problem.AddResidualBlock(cost_function, None, np_arr_to_optimize)
I had the same issue with you. I found it is due to initial_x was set as int type. For example
initial_x = 5
Instead, you should set it like
initial_x = 5.0
All internal computations expect "double" data type as input.
The author may add some casting into ParseNumpyData.
Temporarily,
np_params = np_params.astype(np.float64) if np_params.dtype != np.float32 else np_params
or np_params = np.array(params, dtype=np.float64)
works for me.
Hi,
I'm having a problem getting the final values of parameters. I defined a custom cost function (PyCeres.CostFunction) and used options.linear_solver_type = PyCeres.LinearSolverType.DENSE_QR, with options = PyCeres.SolverOptions(). I also define an initial_x and parameters = np.array(initial_x). However, once the solver converges, the value of parameters is equal to its initial value. I added a print in the cost function inside the cost function and I could see the different values of parameters evaluated at each iteration.
Is there a way to get the final values of parameters once the problem is solved?
Thanks, Azza