求解非线性最小二乘优化问题的python模块
NonlinearLeastSquares的Python项目详细描述
请参阅模块API页
https://engineering.purdue.edu/kak/distNonlinearLeastSquares/NonlinearLeastSquares-2.0.0.html
有关此模块的所有信息,包括 有关代码最新更改的信息。这个 上面显示的url页面列出了所有模块 可以在自己的代码中调用的功能。
关于本单元的基本目的,它提供了 非线性最小二乘的一种不可知域实现 算法(梯度下降和levenberg-marquardt) 将模型与观测数据拟合。通常,模型 包含多个参数和每个观察到的数据元素 可以表示为这些参数加上 噪音。非线性最小二乘的目标是估计 给定所有观测参数的最佳值 数据。为了说明如何使用 非线性最小二乘类,该模块还附带两个 附加类:optimizedsurfacefit和 projectvecamera.
optimizedsurfacefit的工作是将最佳曲面拟合到噪声中 XY平面上的高度数据。本例中的模型将 是高度曲面和 非线性最小二乘法的目标是估计 模型中参数的最佳值。
而projectvecamera的工作是演示如何 非线性最小二乘法可用于场景估计 从相机的运动结构。潜在的想法是 你用相机拍摄一个场景的多个图像- 可以用projectvecamera模拟的东西。 将这样记录的像素输入 非线性最小二乘类估计 当使用未校准的 摄像机,也可以估计 每个位置的摄像机。
从版本2.0.0开始,该模块包括 levenberg-marquardt的束调整变量 算法。
调用域不可知的典型用法语法 通过您自己的特定于域的类的非线性lastsquares 例如优化曲面拟合或projectveCamera如下所示:
optimizer = NonlinearLeastSquares( max_iterations = 200, delta_for_jacobian = 0.000001, delta_for_step_size = 0.0001, ) surface_fitter = OptimizedSurfaceFit( gen_data_synthetically = True, datagen_functional = "7.8*(x - 0.5)**4 + 2.2*(y - 0.5)**2", data_dimensions = (16,16), how_much_noise_for_synthetic_data = 0.3, model_functional = "a*(x-b)**4 + c*(y-d)**2", initial_param_values = {'a':2.0, 'b':0.4, 'c':0.8, 'd':0.4}, display_needed = True, debug = True, ) surface_fitter.set_constructor_options_for_optimizer(optimizer) result = surface_fitter.calculate_best_fitting_surface('lm') or result = surface_fitter.calculate_best_fitting_surface('gd') OR optimizer = NonlinearLeastSquares.NonlinearLeastSquares( max_iterations = 400, delta_for_jacobian = 0.000001, delta_for_step_size = 0.0001, ) camera = ProjectiveCamera.ProjectiveCamera( camera_type = 'projective', alpha_x = 1000.0, alpha_y = 1000.0, x0 = 300.0, y0 = 250.0, ) camera.initialize() world_points = camera.make_world_points_for_triangle() world_points_xformed = camera.apply_transformation_to_generic_world_points(world_points, ..... ) ## Now move the camera to different positions and orientations and then result = camera.get_scene_structure_from_camera_motion('lm') OR result = camera.get_scene_structure_from_camera_motion_with_bundle_adjustment()