记录Ceres优化中遇到的一个奇怪问题

2023-05-16

笔者在学习视觉SLAM十四讲的第6讲非线性优化时,运行使用Ceres拟合曲线的例程,发现当生成数据为如下代码时

  vector<double> x_data, y_data;      // 数据
  for (int i = 0; i < N; i++) {
    double x = i / 100.0;
    x_data.push_back(x);
    double real = exp(ar * x * x + br * x + cr);
    double gauss_noise = rng.gaussian(w_sigma * w_sigma);
    y_data.push_back(real + gauss_noise);
    // rng.gaussian(w_sigma * w_sigma);
  }

输出为

solve time cost = 0.000777462 seconds.
Ceres Solver Report: Iterations: 8, Initial cost: 1.597873e+06, Final cost: 5.096851e+01, Termination: CONVERGENCE
estimated a,b,c = 0.890908 2.1719 0.943628

当把注释去掉,即为如下代码时

vector<double> x_data, y_data; // 数据
  for (int i = 0; i < N; i++)
  {
    double x = i / 100.0;
    x_data.push_back(x);
    double real = exp(ar * x * x + br * x + cr);
    double gauss_noise = rng.gaussian(w_sigma * w_sigma);
    y_data.push_back(real + gauss_noise);
    rng.gaussian(w_sigma * w_sigma); //按理来说此行不应该影响结果。 此处替换为其他无关语句时,结果不受影响
  }

输出结果为

solve time cost = 0.000914116 seconds.
Ceres Solver Report: Iterations: 7, Initial cost: 1.599017e+06, Final cost: 5.808070e+01, Termination: CONVERGENCE
estimated a,b,c = 1.05448 1.92195 1.02832

即优化得到了一个更好的结果,重复运行了多次都是这样。
在这里插入图片描述

画出曲线,发现这两套参数拟合的结果与真实值都很接近。
在这里插入图片描述
将数据点增加到一万个时,有注释结果如下

solve time cost = 0.0271037 seconds.
Ceres Solver Report: Iterations: 8, Initial cost: 1.624262e+08, Final cost: 5.071043e+03, Termination: CONVERGENCE
estimated a,b,c = 1.02485 1.96084 1.01517

无注释即多运行一次rng.gaussian结果如下

solve time cost = 0.10454 seconds.
Ceres Solver Report: Iterations: 8, Initial cost: 1.623919e+08, Final cost: 4.873203e+03, Termination: CONVERGENCE
estimated a,b,c = 1.00244 1.99048 1.00779

可见数据量增大后,能够较好的拟合曲线。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

记录Ceres优化中遇到的一个奇怪问题 的相关文章

  • Ubuntu安装Ceres库

    Ubuntu安装Ceres库 一 添加源方法一 xff1a 手动添加镜像源到sources list方法二 xff1a 指令添加镜像源到sources list 二 安装依赖库指令 三 Ceres库的下载四 Ceres库的安装1 解压缩2
  • win10安装ceres环境

    ceres是一个开源的c 43 43 库 xff0c 在windows上安装有点复杂 xff0c 它依赖其他三个库 Eigen gflags glog 好在这些依赖都可以通过源码安装 在windows上进行源码编译安装 xff0c 需要对应
  • G2o,GTSAM,Ceres,Tensorflow优化器的方法比较(转载)

    转载自 xff1a https blog csdn net ziliwangmoe article details 86561157
  • SLAM本质剖析-Ceres

    转载自 xff1a https mp weixin qq com s fKlG9LWlPI52wStUAv18iw SLAM本质剖析 Ceres 原创 lovely yoshino 古月居 今天 在了解SLAM的原理 流程后 xff0c 个
  • Ubuntu 20.04.05安装ceres-1.14.0

    1 安装Ceres1 14 0 链接 Ubuntu20 04安装Ceres1 14 0 3 cmake编译ceres遇到的问题 xff08 1 xff09 TBB 问题描述 xff1a Did not find Intel TBB libr
  • Ceres-solver安装(win10+vs2015)

    Ceres solver安装 Vs2015 43 win10 文件已经上传至 永久有效 网盘 xff1a https pan baidu com s 1Vj n2Nbp9WFVlbjuXV OxQ 密码 xff1a 3rvo 1 将网盘里的
  • 非线性优化库学习资料:Ceres Gtsam G2o

    其中 Ceres 资料最完善也相对稳定 xff0c 是谷歌的非线性优化库 xff0c Google Cartographer 就是调用了该库 http www ceres solver org tutorial html 既可以作为 Cer
  • slam优化eigen,ceres,g2o,gtsam,pcl

    eigen SLAM本质剖析 Eigen 古月居 ceres https guyuehome com 34633 g2o SLAM本质剖析 G2O 古月居 gtsam SLAM本质剖析 GTSAM 古月居 pcl https www guy
  • 未安装Ceres

    编译VINs的时候 xff0c 遇到了这个问题 xff0c 是没安装Ceres导致的 96 CMake Error at VINS Mono camera model CMakeLists txt 19 find package By no
  • Building ceres-solver fail with eigen3 "error: no type named ‘Literal’ in ‘struct Eigen::NumTraits"

    以前编译ceres solver没有出现过问题 xff0c 最近在编译时报出一个问题 xff1a 75 Building CXX object internal ceres CMakeFiles jet test dir jet test
  • Ceres使用经验之柯西核函数

    原理 在优化中 xff0c 经常会遇见有异常值的情况 xff0e 如在直线拟合中 xff0c 可能会出现若干个不在直线上点 xff0c 此时如果每一个点的权重一样 xff0c 就会导致求得的直线方程不理想 xff0e 为了增强优化过程中对异
  • SLAM中姿态估计的图优化方法比较(g2o/Ceres/GTSAM/SE-Sync)

    编辑 深蓝AI 点击下方卡片 xff0c 关注 自动驾驶之心 公众号 ADAS巨卷干货 xff0c 即可获取 后台回复 SLAM综述 获取视觉SLAM 激光SLAM RGBD SLAM等多篇综述 xff01 本文是对论文 A Compari
  • 用Ceres实现PnP

    在ceres中实现PnP优化 xff08 仅优化位姿 xff09 视觉SLAM十四讲 课后习题 ch7 xff08 更新中 xff09
  • Ceres 详解(一) Problem类

    引言 Ceres 是由Google开发的开源C 43 43 通用非线性优化库 xff08 项目主页 xff09 xff0c 与g2o并列为目前视觉SLAM中应用最广泛的优化算法库 xff08 VINS Mono中的大部分优化工作均基于Cer
  • 安装kalibr踩坑2:fatal error: ceres/rotation.h: No such file or directory #include “ceres/rotation.h“

    fatal error ceres rotation h No such file or directory include 34 ceres rotation h 34 ceres没有装好 xff0c 需要重装 xff0c 安装方法如下
  • cartographer之ceres编译

    1 首先下载ceres xff1b 2 进入ceres目录 xff1b 3 mkdir build amp amp cd build 4 cmake DEIGENSPARSE 5 make 6 sudo make install
  • ubuntu16.04下编译ceres-solver

    一 编译环境 ubuntu16 04 二 准备工作之安装必要的库 2 1安装cmake sudo apt get install cmake 2 2 安装google glog 43 gflags sudo apt get install
  • Ceres的自动求导实现原理剖析

    目录 数学原理实现原理总结 首先注意数值求导和自动求导在使用的时候的不同之处 实际上 xff0c 正是自动求导这个地方使用了类模板 xff0c 导致它不仅可以传入参数 xff0c 还可以传入Jet类型的数据 xff0c 从而实现了参数的雅可
  • Ceres 自动求导解析-从原理到实践

    Ceres 自动求导解析 从原理到实践 文章目录 Ceres 自动求导解析 从原理到实践1 0 前言2 0 Ceres求导简介3 0 Ceres 自动求导原理3 1 官方解释3 2 自我理解 4 0 实践4 1 Jet 的实现4 2 多项式
  • ubuntu 20.04 安装 ceres库

    文章目录 一 安装依赖项二 下载源码 xff1a 三 编译并且安装1 进入正确位置 xff1a 2 建立build xff0c 并进入3 编译4 安装 安装完成后是下面这个界面 xff1a 一 安装依赖项 sudo apt span cla

随机推荐