当前位置: 首页 > news >正文

桂林网站建设官网百度关键词优化有效果吗

桂林网站建设官网,百度关键词优化有效果吗,用新华做网站名是否侵权,风景网页设计图片之前用过Ceres,但是只是跑例程,现在来着重学习一下使用流程。 1. 解决的问题 主要解决非线性优化问题。Ceres是一个较为通用的库。 参考链接 2. 如何使用 这个是求解的函数,主要关注这三个参数 CERES_EXPORT void Solve(const Solver::O…

之前用过Ceres,但是只是跑例程,现在来着重学习一下使用流程。

1. 解决的问题

主要解决非线性优化问题。Ceres是一个较为通用的库。
参考链接

2. 如何使用

这个是求解的函数,主要关注这三个参数

CERES_EXPORT void Solve(const Solver::Options& options, Problem* problem, Solver::Summary* summary);

1. options

与优化相关的一些参数配置

2. problem

定义problem
重要的函数

  ResidualBlockId AddResidualBlock(CostFunction* cost_function,LossFunction* loss_function,const std::vector<double*>& parameter_blocks);

其中cost_function是需要我们自己定义的代价函数,拿SLAM14讲中的CURVE_FITTING_COST为例

添加残差项:

    ceres::Problem problem;for(int i=0; i<N; ++i){  //100个点句添加100个误差项//使用自动求导problem.AddResidualBlock(new ceres::AutoDiffCostFunction<CURVE_FITTING_COST, 1, 3>(new CURVE_FITTING_COST(x_data[i], y_data[i])),nullptr,abc  //待估计参数,可在此处给初值);}

其中,AddResidualBlock
@param1ceres::AutoDiffCostFunction是用自动求导的方式,是一个类模板,需要传入参数类型实例化为模板类(类名,输出维度(标量误差,维度1),输入维度(abc三个参数,维度3)),然后传入实际参数来实例化出一个类,(也可以自己求雅克比传给ceres,这里不多说)
@param2 核函数一般不用,传nullptr
@param3 待估计参数(由于非线性优化对初值敏感,所以可以从这里传入待优化变量的初值)

关于残差项的构建:

using namespace std;
struct CURVE_FITTING_COST{CURVE_FITTING_COST(double x, double y):_x(x), _y(y){}  //构造函数需要传入的对象template<typename T>bool operator()(const T *const abc, T *residual) const {residual[0] = T(_y) - ceres::exp(abc[0] * T(_x) * T(_x) + abc[1] * T(_x) + abc[2]);return true;}const double _x, _y;
};

重载operator()
@param1 :输入参数,三维待估计参数。
@param2 :输出参数,一维误差。
这个函数就是用输入的参数通过计算,算出残差用于求导。

3. summary

用于保存优化log(日志)

3. 求导方式

3.1 自行求导

求导方式有自行求导和Autodiff
自行求导需要继承ceres::SizedCostFunction,并重载Evaluate()函数自行推导导数计算jacobians,parameters传入的即为待优化参数,
调用:

            CameraLidarFactor *f = new CameraLidarFactor(Rl1_l2, tl1_l2, _z);  //求导方式problem.AddResidualBlock(f, new ceres::HuberLoss(1e-6), &_phi, _t);  //第三部分为待优化参数,可赋初值

具体实现:

class CameraLidarFactor : public ceres::SizedCostFunction<2, 1, 2> {  //第一个是输出维度,phi和t一个1维,一个2维
public:CameraLidarFactor(Matrix2d &Rl1_l2, Vector2d &tl1_l2, Vector2d &z) :  // 待优化的phi,lidar系下的平移Rl1_l2(Rl1_l2), tl1_l2(tl1_l2), z_(z) {}virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const {double phi_l_lc = parameters[0][0];Matrix2d Rl_lc;  // rot2d_from_yawRl_lc << cos(phi_l_lc), -sin(phi_l_lc),sin(phi_l_lc), cos(phi_l_lc);Vector2d tl_lc(parameters[1][0], parameters[1][1]);Vector2d thc1_hc2 = (-tl_lc + tl1_l2 + Rl1_l2 * tl_lc);  // -(l1)tl1_lc1 + (l1)tl1_l2 + Rl1_l2 * (l2)tl2_lc2Map<Vector2d> residual(residuals);residual = Rl_lc.inverse() * thc1_hc2 - z_;  //(hc1)thc1_hc2' - (hc1)thc1_hc2if (jacobians) {if (jacobians[0]) {Matrix2d Rl_hc_inverse_prime;Rl_hc_inverse_prime << -sin(phi_l_lc), cos(phi_l_lc),  //逆求导-cos(phi_l_lc), -sin(phi_l_lc);Map<Matrix<double, 2, 1>> jacobian_phi(jacobians[0]);jacobian_phi = Rl_hc_inverse_prime * thc1_hc2;}if (jacobians[1]) {Map<Matrix<double, 2, 2, RowMajor>> jacobian_t(jacobians[1]);jacobian_t = Rl_lc.inverse() * (Rl1_l2 - Matrix2d::Identity());}}return true;}Matrix2d Rl1_l2;Vector2d tl1_l2, z_;
};

3.2 Autodiff自动求导

在定义costfunction时选择ceres::AutoDiffCostFunction使用自动求导,求数值导数,需要重载operator()。

**注意:**这里重载operator需要是函数模板,里面所有的数据都要使用模板的数据类型。

调用:

        ceres::CostFunction *cost_function = NULL;cost_function = CamTiltFactor::Create(init_z, image_poses_[i].second.translation());problem.AddResidualBlock(cost_function, new ceres::HuberLoss(1e-5), para_qic);

实现:

struct CamTiltFactor {CamTiltFactor(const double init_z, const Eigen::Vector3d trans) :init_z_(init_z), trans_(trans) {}static ceres::CostFunction *Create(const double init_z, Eigen::Vector3d trans) {return new ceres::AutoDiffCostFunction<CamTiltFactor, 1, 4>(new CamTiltFactor(init_z,  trans));}template<typename _T2>bool operator()(const _T2 *const para_qic, _T2 *residuals) const {//计算residualspara_qic[0]Eigen::Quaternion<_T2> _quat{para_qic[0], para_qic[1], para_qic[2], para_qic[3]};Eigen::Matrix<_T2, 3, 1> tmp_trans_(_T2(trans_.x()), _T2(trans_.y()), _T2(trans_.z()));Eigen::Matrix<_T2, 3, 1> _t_rotated = _quat * tmp_trans_;  //使用重载的乘法residuals[0] = _T2(_t_rotated.z()) - _T2(init_z_);  //残差return true;}Vector3d trans_;double init_z_;
};

另外,当四元数为优化的对象时,需要调用ceres::QuaternionParameterization来消除自由度冗余

    double para_qic[4] = {1, 0, 0, 0};problem.AddParameterBlock(para_qic, 4, new ceres::QuaternionParameterization);

文章转载自:
http://wanjiaderidingly.rkck.cn
http://wanjiacalyptrogen.rkck.cn
http://wanjiaheathberry.rkck.cn
http://wanjiainfauna.rkck.cn
http://wanjiasjaelland.rkck.cn
http://wanjiavolatility.rkck.cn
http://wanjiasouthpaw.rkck.cn
http://wanjiaaphasia.rkck.cn
http://wanjiajinker.rkck.cn
http://wanjiapotful.rkck.cn
http://wanjiaavoid.rkck.cn
http://wanjiaectal.rkck.cn
http://wanjiaoutwards.rkck.cn
http://wanjiacolonel.rkck.cn
http://wanjiafining.rkck.cn
http://wanjiaaristaeus.rkck.cn
http://wanjiavespertilionine.rkck.cn
http://wanjiavext.rkck.cn
http://wanjiahematal.rkck.cn
http://wanjiamechanoreceptor.rkck.cn
http://wanjiametallic.rkck.cn
http://wanjiachlorophyllite.rkck.cn
http://wanjiasouvlaki.rkck.cn
http://wanjiapre.rkck.cn
http://wanjiapitiably.rkck.cn
http://wanjiamuckamuck.rkck.cn
http://wanjiastratocirrus.rkck.cn
http://wanjiaturtle.rkck.cn
http://wanjiaindisputable.rkck.cn
http://wanjiaphenolate.rkck.cn
http://wanjiaserviceman.rkck.cn
http://wanjiaflexuose.rkck.cn
http://wanjialoom.rkck.cn
http://wanjiacronyism.rkck.cn
http://wanjiadumbness.rkck.cn
http://wanjiaeighthly.rkck.cn
http://wanjiaploughback.rkck.cn
http://wanjiadhl.rkck.cn
http://wanjialocofoco.rkck.cn
http://wanjiafloriated.rkck.cn
http://wanjiamoxibustion.rkck.cn
http://wanjiagallization.rkck.cn
http://wanjiavulgarly.rkck.cn
http://wanjiadisuse.rkck.cn
http://wanjiaindagator.rkck.cn
http://wanjiaalbedo.rkck.cn
http://wanjiamigraineur.rkck.cn
http://wanjiaendosteum.rkck.cn
http://wanjiaacutilingual.rkck.cn
http://wanjiagrieved.rkck.cn
http://wanjiarubefacient.rkck.cn
http://wanjiathundercloud.rkck.cn
http://wanjiabicrural.rkck.cn
http://wanjiatlac.rkck.cn
http://wanjiaincludable.rkck.cn
http://wanjiaanorgastic.rkck.cn
http://wanjiaoverblown.rkck.cn
http://wanjiamicrocapsule.rkck.cn
http://wanjiaauteur.rkck.cn
http://wanjiaeriophyllous.rkck.cn
http://wanjiaoaves.rkck.cn
http://wanjiaahull.rkck.cn
http://wanjiamicrohardness.rkck.cn
http://wanjiaprocessional.rkck.cn
http://wanjiafarinose.rkck.cn
http://wanjiaquamash.rkck.cn
http://wanjiayellowlegs.rkck.cn
http://wanjiathundersquall.rkck.cn
http://wanjiabursectomize.rkck.cn
http://wanjiaswine.rkck.cn
http://wanjiamycetozoan.rkck.cn
http://wanjiasquiggly.rkck.cn
http://wanjiagemmuliferous.rkck.cn
http://wanjiasignifiant.rkck.cn
http://wanjiasupercoil.rkck.cn
http://wanjiaatonal.rkck.cn
http://wanjianereis.rkck.cn
http://wanjiagaborone.rkck.cn
http://wanjiacrocus.rkck.cn
http://wanjiamarital.rkck.cn
http://www.15wanjia.com/news/110593.html

相关文章:

  • 查看网站是什么空间网站seo入门基础教程书籍
  • 东营做营销型网站俄罗斯搜索引擎入口
  • 国外的服务器建设的网站东莞seo排名公司
  • 江苏住房和城乡建设委员会网站韶关新闻最新今日头条
  • 淘宝客网站开发软文推广什么意思
  • wordpress底部主题如何做网站优化seo
  • 博兴做网站企业培训方案制定
  • 贵州网站推广公司百度非企渠道开户
  • wordpress 评论框插件武汉seo诊断
  • 真实企业vi设计案例欣赏seo整站优化方案
  • 台州网站推广优化怎样通过网络销售自己的产品
  • 免费个人网站建设公司一个自己的网站
  • 360网站推广如何推广app赚钱
  • 特效很好的网站seo公司软件
  • 做视频上传多少个网站移投界seo
  • 什么是网站原创文章服务之家网站推广
  • 湖北工程造价信息网整站多关键词优化
  • 河南企起网站建设影响关键词优化的因素
  • 采集网站如何收录营销团队
  • 做网站需要什么语言推广的公司
  • 做网站需要那些技术网站页面分析
  • 用hbuilder做网站模块北京关键词优化服务
  • 物流网站前端模板下载迅雷磁力
  • 横向网站模板seo关键词快速排名前三位
  • 新品发布会的目的和意义廊坊seo关键词优化
  • asp.net网站备份企业网站设计毕业论文
  • 中国国家城乡建设部网站个人免费推广网站
  • 长春视频剪辑培训机构西安seo网络推广
  • 高能建站app推广平台
  • 1做网站搜索引擎优化包括哪些