ceres快速教材及学习笔记(四)bundl adjustment,《视觉slam十四讲》第十讲ceres例子

Ceres Solver 官方教程学习笔记(五)——光束法平差Bundle Adjustment 本文主要根据Ceres官方教程翻译的来。 开发Ceres库的一个重要出发点就是计算光束法平差Bundle Adjustment,简称BA。 关于光束法平差的原理可以参考这篇博客《Bundle Adjustment简述》 现简单的概况如下: 空间中一个点在成像平面的坐标系中投影成一个像素。这个投影称为初次投影。如果我们有多个相机,可以根据空间中同一点在不同相机中的投影(即像素坐标)来反... 阅读详情

0. 前言
本文是根据ceres官方教程内容ceres-solver官方教程链接,再结合自己理解的一个ceres快速学习笔记。
在博文ceres快速教材及学习笔记(一)hello,world!中,我们学习了

最小二乘问题数学模型;
弄清楚了各个参数的意义;
利用学习的最小二乘问题数学模型和ceres解决了一个最简单的最小二乘问题;

在博文ceres快速教材及学习笔记(二)曲线拟合,稍复杂的例子中,我们学会了怎样使用多个参数块,如何添加多个误差项。接下来在此基础上我们来求解更加复杂的问题,以处理如何使不同的误差项有不同代价函数以及参数块的情况。
在博文,ceres快速教材及学习笔记(三)鲍威尔方程Powell’s Function,中何使不同的误差项有不同代价函数以及参数块的情况。
接下来,在《视觉slam十四讲》第十讲ceres例子(源码在这里)中,我们将学会bundle adjustment。学会处理每个误差项输出维度不为一的情况

1.Bundle Adjustment
1.1准备工作

该项目分为以下几个步骤以实现bundle adjustment。

设置参数
读取ground truth 真实值
将真实值转化格式后输出initial.ply
基于真实值加入perturbation,也就是噪声,来模拟实际情况中获得的数据。
基于加了噪声的数据进行bundle adjustment。
输出BA之后的数据生成final.ply

在项目提供一个problem-16-22106-pre.txt文件:

16 22106 83718
0 0     -3.859900e+02 3.871200e+02
1 0     -3.844000e+01 4.921200e+02
2 0     -6.679200e+02 1.231100e+02
7 0     -5.991800e+02 4.079300e+02
12 0     -7.204300e+02 3.143400e+02
13 0     -1.151300e+02 5.548999e+01
0 1     3.838800e+02 -1.529999e+01

其含义,在提供该数据的官方网站上能找到:

<num_cameras> <num_points> <num_observations>
<camera_index_1> <point_index_1> <x_1> <y_1>
...
<camera_index_num_observations> <point_index_num_observations> <x_num_observations> <y_num_observations>
<camera_1>
...
<camera_num_cameras>
<point_1>
...
<point_num_points>

翻译
假设相机数量为m,路标点数量为n,观测数量为ob,则

<m> <n> <ob>
<观测1使用的相机序号> <观测1看到的路标点> <此次观测的路标点在图像中的位置x_1> <此次观测的路标点在图像中的位置y_1>
...
<观测ob使用的相机序号> <观测ob看到的路标点> <观测1看到的路标点x_ob> <观测1看到的路标点y_ob>
<相机1参数>
...
<相机m参数>
<路标点1参数>
...
<路标点n参数>

1.2问题思考

思考以下问题
首先,回答以下问题:(以下参数的各个含义点击这里):

 

1.3.代码讲解

先来看main函数

int main(int argc, char** argv)
{    //设置参数
    BundleParams params(argc,argv);  // set the parameters here.
   
    google::InitGoogleLogging(argv[0]);
    std::cout << params.input << std::endl;
    if(params.input.empty()){
        std::cout << "Usage: bundle_adjuster -input <path for dataset>";
        return 1;
    }
	//求解BA
    SolveProblem(params.input.c_str(), params);
 
    return 0;
}

进入SolveProblem函数

void SolveProblem(const char* filename, const BundleParams& params)
{
    //读取文件
    BALProblem bal_problem(filename);

    // show some information here ...
    std::cout << "bal problem file loaded..." << std::endl;
    std::cout << "bal problem have " << bal_problem.num_cameras() << " cameras and "
              << bal_problem.num_points() << " points. " << std::endl;
    std::cout << "Forming " << bal_problem.num_observations() << " observatoins. " << std::endl;

    // store the initial 3D cloud points and camera pose..
    //储存初始的(未BA前的)3d点云位置以及相机位置
    if(!params.initial_ply.empty()){
        bal_problem.WriteToPLYFile(params.initial_ply);
    }

    std::cout << "beginning problem..." << std::endl;
    
    // add some noise for the intial value
    //给camera,points都加上噪音
    srand(params.random_seed);
    bal_problem.Normalize();
    bal_problem.Perturb(params.rotation_sigma, params.translation_sigma,
                        params.point_sigma);

    std::cout << "Normalization complete..." << std::endl;
    
    //开始构建最小二乘问题啦
    Problem problem;
    //具体构建的细节在这个函数里
    BuildProblem(&bal_problem, &problem, params);

    std::cout << "the problem is successfully build.." << std::endl;
   
   	//配置求解器
    Solver::Options options;
    SetSolverOptionsFromFlags(&bal_problem, params, &options);
    options.gradient_tolerance = 1e-16;
    options.function_tolerance = 1e-16;
    Solver::Summary summary;
    Solve(options, &problem, &summary);
    std::cout << summary.FullReport() << "\n";
	
	//导出未BA后的3d点云位置以及相机位置
    // write the result into a .ply file.   
    if(!params.final_ply.empty()){
        bal_problem.WriteToPLYFile(params.final_ply);  
        // pay attention to this: ceres doesn't copy the value into optimizer, but implement on raw data! 
    }
}

接下来看看BuildProblem(&bal_problem, &problem, params);看他如何构建BA问题

void BuildProblem(BALProblem* bal_problem, Problem* problem, const BundleParams& params)
{
    const int point_block_size = bal_problem->point_block_size();
    const int camera_block_size = bal_problem->camera_block_size();
    double* points = bal_problem->mutable_points();//构建points参数类型的优化变量
    double* cameras = bal_problem->mutable_cameras();//构建cameras参数类型的优化变量

    // Observations is 2 * num_observations long array observations
    // [u_1, u_2, ... u_n], where each u_i is two dimensional, the x 
    // and y position of the observation. 
    const double* observations = bal_problem->observations();
	//有观测数量有多少就有多少误差项
    for(int i = 0; i < bal_problem->num_observations(); ++i){
        CostFunction* cost_function;

        // Each Residual block takes a point and a camera as input 
        // and outputs a 2 dimensional Residual
      	//在这里构建代价函数costfunction每个误差块是以一个points和一个cameras为输入的
        cost_function = SnavelyReprojectionError::Create(observations[2*i + 0], observations[2*i + 1]);

        // If enabled use Huber's loss function. 
        //设置是否开启核函数
        LossFunction* loss_function = params.robustify ? new HuberLoss(1.0) : NULL;

        // Each observatoin corresponds to a pair of a camera and a point 
        // which are identified by camera_index()[i] and point_index()[i]
        // respectively.
        double* camera = cameras + camera_block_size * bal_problem->camera_index()[i];
        double* point = points + point_block_size * bal_problem->point_index()[i];

     
        problem->AddResidualBlock(cost_function, loss_function, camera, point);
    }

}

接下来看看SnavelyReprojectionErrorcostfunction

class SnavelyReprojectionError
{
public:
    SnavelyReprojectionError(double observation_x, double observation_y):observed_x(observation_x),observed_y(observation_y){}
//重载()以获得一个仿函数functor
template<typename T>
    bool operator()(const T* const camera,
                const T* const point,
                T* residuals)const{                  
        // camera[0,1,2] are the angle-axis rotation
        T predictions[2];
        CamProjectionWithDistortion(camera, point, predictions);
        //输出维度是2,代表着你在图像中观测到的路标点的像素坐标
        residuals[0] = predictions[0] - T(observed_x);
        residuals[1] = predictions[1] - T(observed_y);

        return true;
    }

    static ceres::CostFunction* Create(const double observed_x, const double observed_y){
    //在这里返回代价函数,这里是自动求导的,模版参数分别为<仿函数类型,误差项输出维度r,cameras维度s_1,points维度s_2>
        return (new ceres::AutoDiffCostFunction<SnavelyReprojectionError,2,9,3>(
            new SnavelyReprojectionError(observed_x,observed_y)));
    }


private:
    double observed_x;
    double observed_y;
};

更多《计算机视觉与图形学》知识,可关注下方公众号:

光束平差(Bundle Adjustment)源代码 sba一个通用的稀疏光束法平差的软件包,可以用于摄影测量软件开发 立即下载

相关推荐

SLAM专题(10)- 最小化重投影误差与Bundle Adjustment (BA)

在SFM(structure from motion)的计算中BA(Bundle Adjustment)作为最后一步优化具有很重要的作用,在近几年兴起的基于图的SLAM(simultaneous localization and mapping)算法里面使用了图优化替代了原来的滤波器,这里所谓的图优化其实也是指BA。其实很多经典的文献对于BA都有深深浅浅的介绍,如果想对BA的全过程做一个全面的更深层次的了解,推荐阅读 Bundle Adjustment —A Modern Synthesis. 目录 一. 历史由来 二. Bundle Adjustment到底是什么? 平差也就正好表述了为什么

Ceres简介及示例(5)Bundle Adjustment

第一步通常是定义一个模板化的仿函数来计算重投影误差/残差。仿函数的结构类似于ExponentialResidual,因为每个图像观测都有一个该对象的实例。相机内参模型有焦距f和畸变参数k1、k2给出,这里将fx和fy等同起来,另外模型中没有cx和cy,因为存储数据中已经去掉,计算不参与。BAL数据在投影时假设投影平面在相机光心之后,与假设的小孔成像模型投影平面在相机光心之前相反,因此需要在投影之后乘以系数-1。BAL问题中的每个残差都依赖于一个三维点和九个相机参数。

热爱生活,忠于自己 1792

frontend-design skills

frontend-design skills

Ceres 计算 Bundle Adjustment

这是一篇 Ceres 求解 BA 的实战教程,围绕 SfM 与 SLAM 后端核心光束法平差展开。BA 从共线条件方程出发,最小化重投影误差平方和,联合优化相机位姿与三维点坐标,属非线性最小二乘。代码给出重投影误差 functor,相机 9 参数(轴角、平移、焦距、两阶径向畸变)、点 3 参数,推荐走自动微分并加 HuberLoss 抗外点。线性求解器首选 Schur 系列利用 BA 稀疏结构,百万级观测是标配。最后提到 LocalParameterization 防参数越界,强调先看收敛再看耗时。

人无远虑,必有近忧 2194

告别环境报错:用Pycharm一站式搞定Superset 3.0.0二次开发环境(Windows/Mac通用)

本文详细介绍了如何使用Pycharm一站式搭建Apache Superset 3.0.0的二次开发环境,涵盖Windows和Mac平台。通过虚拟环境配置、依赖管理、数据库初始化及前后端协同开发等步骤,帮助开发者高效解决环境报错问题,提升开发效率。特别适合需要进行Superset二次开发的工程师参考。

weixin_42549496的博客 316

为什么传统CNN在视网膜分割中败给Mamba?从血管拓扑学揭秘Serp-Mamba的蛇形扫描黑科技

本文深入分析了传统CNN在视网膜血管分割任务中的局限性,特别是在处理高分辨率图像和复杂血管拓扑结构时。针对这些问题,文章重点介绍了Serp-Mamba模型的核心创新——蛇形交织自适应扫描(SIA)机制,该机制通过让扫描路径自适应地贴合血管曲率,并结合模糊驱动双重校准(ADDR)模块应对极端类别失衡,从而在视网膜血管分割任务上实现了性能的显著突破。

ss78901的博客 898

非线性优化库Ceres学习笔记8(Bundle Adjustment)

开发Ceres的主要原因之一是我们需要解决大规模的Bundle Adjustment,简称BA。 给定一组测量的图像特征和对应关系,Bundle Adjustment的目标是找到使重投影误差最小的3D点位置和相机参数。这个优化问题通常被描述为非线性最小二乘法问题,要最小化的目标函数即为测得图像中特征点位置和相机成像平面上的对应的投影之间的差的平方。Ceres例程使用了BAL数据集 。 第一步是...

JunJun 2514

PSI5协议技术文档与驱动开发指南

• 供电与数据复用:ECU通过双绞线为传感器提供稳压(典型值5V-11V),同时检测线路电流变化实现数据传输。• 同步信号:ECU发送3.5V电压脉冲(上升沿触发传感器响应),用于时序同步。• 安全气囊:PSI5-P模式实现多碰撞传感器同步采样(响应时间<10ms)• CRC-3(3位):ASIL-B以上功能安全要求(如动力总成传感器)• 奇偶校验(1位):适用于低安全等级场景(如PSI5-P10P模式)• 典型应用:PSI5-P(并行总线)、PSI5-U(通用总线)

u012733413的博客 2872

Ceres计算Bundle Adjustment

Bundle Adjustment,中文名称是光束法平差,经典的BA目的是优化相机的pose和landmark,其在SfM和SLAM 领域中扮演者重要角色。开发Ceres的主要原因之一是需要解决大规模的Bundle Adjustment. 目前bundle adjustment 优化框架最为代表的是ceres solver和g2o ,据说ceres的命名是天文学家Piazzi闲暇无事的时候观测一颗没有观测到的星星,最后用least squares算出了这个小行星的轨道,故将这个小行星命名为ceres。

nuc_baixu的博客 781

CorelDRAW 2019安装指南:从下载到激活的完整步骤

本文提供了一份详细的CorelDRAW 2019安装指南,涵盖从下载安装包、检查系统环境到完成激活的完整步骤。文章重点解析了安装过程中的关键选项设置,并分享了首次启动后的优化配置与常见问题解决方案,旨在帮助用户高效、顺利地完成这款经典矢量设计软件的安装与配置。

weixin_29213827的博客 851

Jira Software 8.19.0

通过 Docker Compose 部署 Jira 8.19.0 能够极大地简化运维复杂度。数据库版本匹配(8.x 配 Postgres 11)。健康检查(避免启动竞态条件)。数据持久化(挂载 volume)。完成上述步骤后,你就拥有了一套完全由自己掌控数据的项目管理系统。记得定期备份/data/jira目录!

qq_43180307的博客 968

SLAM新手必看:如何用Ceres Solver实现Bundle Adjustment(附完整代码)

本文详细介绍了如何使用Ceres Solver实现Bundle Adjustment(光束法平差),这是视觉SLAM和三维重建中的核心优化技术。通过基础概念讲解、环境配置、问题建模、完整代码实现及优化技巧,帮助SLAM新手快速掌握BA技术,提升三维测量和建模精度。

weixin_29296241的博客 121

华为OD机试 - 第k个排列 - 全排列递归(Python/JS/C/C++ 2025 C卷 100分)

给定参数n,从1到n会有n个整数:1,2,3,…,n,这n个数字共有n!按大小顺序升序列出所有排列的情况,并一一标记当n=3时,所有排列如下“123”,“132,“213”,“231”,“312”,“321”输入两行,第一行为n,第二行为k,给定n的范围是[1,9],给定k的范围是[1,n!排列为“12”和“21”,第2个是“21”。给定n和k,返回第k个排列。输出排在第k位置的数字。只有一个排列,直接返回。

学Java,找哪吒 991

ceres实现针孔相机bundle adjustment

参考ceres的tutorial http://ceres-solver.org/nnls_tutorial.html#bundle-adjustment 实现针孔相机bundle adjustment 主要工作如下: (1)生成理想观测数据 (2)将生成理想的数据作为BD的输入源 (3)将投影模型改为无畸变的针孔模型 #include &amp;lt;ros/ros.h&amp;gt; #include &amp;lt...

沧海一帆的专栏 2092

【OpenClaw从入门到精通】第24篇:OpenClaw Skill商业化实战指南——从0开发付费技能,在ClawHub变现(2026实测版)

本文聚焦OpenClaw Skill商业化的全流程落地,基于2026年生态现状、公开行业报告及开发者指南,拆解付费Skill的市场机会、商业模式、技术实现、发布运营及避坑要点。核心围绕“Freemium API Backend”主流路径,通过虚拟但贴合真实场景的“金融研报复现”案例,提供从需求分析、定价设计到代码开发、ClawHub上架的完整实操方案。文中包含可直接复用的代码片段、执行结果演示及流程图解,既满足新手快速入门的需求,也为进阶开发者提供商业化落地的关键思路,帮助读者抓住AI Agent早期红利。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1091

【ubuntu24.04】auto remove后,重启,kernel panic ,please reboot your computer vfs unable to mount root fs

Ubuntu 24.04系统在运行auto remove后出现内核恐慌(kernel panic)无法启动,显示"VFS: unable to mount root fs"错误。该问题是由于当前内核被清除导致系统无法挂载根分区。解决步骤包括:1)尝试用GRUB菜单中的旧内核启动;2)在GRUB中临时编辑启动参数;3)使用Ubuntu启动盘进行chroot修复;4)使用Boot-Repair工具一键修复。成功启动后,需要重新安装linux-generic等元包,重建initramfs并更新

突围 1218

Ceres-Solver学习笔记(3)

Ceres BA的例子

少年的此间 8533

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

视觉SLAM十四讲CH9代码解析及课后习题详解

点云查看工具CloudCompare安装: 方法1: 命令行安装: sudo snap install cloudcompare 安装完成后,可以将 ccViewer和CloudCompare添加到任务栏里,也可以使用下面的命令行打开: 打开ccViewer: cloudcompare.ccViewer 打开CloudCompare: cloudcompare.CloudCompare 方法2: 在软件中心中进行安装: ...

生活如此美好,致敬每一个热爱“热爱”的人! 7494

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Ceres的Options详解

目录1、Ceres简介2、常用通用参数 1、Ceres简介 Ceres是一个非常优秀的非线性优化库(谷歌出品)。能完成很复杂的优化功能,选项也非常的多,本篇博客就来梳理下这些选项。 2、常用通用参数 bool Solver::Options::IsValid(string *error) const 检查options是否合法,不合法的话返回false,并将错误信息存到error里面。 i...

Marvek的博客 2万+

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

【ESP32CAM识别图形左边界】(三)识别图像左边界

系列文章目录 ESP32CAM识别图形左边界(一):初步使用ESP32CAM ESP32CAM识别图形左边界(二):网页添加补光灯按钮 ESP32CAM识别图形左边界(三):识别图像左边界 目录 系列文章目录 前言 一、pandas是什么? 二、使用步骤 1.引入库 2.读入数据 总结 前言 之前两篇文章中,第一篇介绍了ESP32-CAM相机的网页使用方法,第二篇介绍了如何在相机的网页中添加自己的内容,最后一篇则真正的开始使用相机里面的图像了,因为我的环境比较简单,...

xanadw的博客 8195

【ESP32CAM识别图形左边界】(二)网页添加补光灯按钮

文章目录 前言 一、pandas是什么? 二、使用步骤 1.引入库 2.读入数据 总结 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。 提示:以下是本篇文章正文内容,下面案例可供参考 一、pandas是什么? 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码如下(示例):

xanadw的博客 5041

Ceres solver中几种常用算法介绍

http://homes.cs.washington.edu/~sagarwal/ceres-solver/stable/solving.html Solving Introduction Effective use of Ceres requires some familiarity with the basic components of a nonlinear leas

stereohomology 1万+

Bundle Adjustment 光束法平差详解

首先引述来自维基百科的定义:假设我们有一个3D空间中的点,他被位于不同位置的多个摄像机看到,那么所谓的光束法平差(Bundle Adjustment),就是能够从这些多视角信息中提取出3D点的坐标以及各个摄像机的相对位置和光学信息的过程。 可能这么说有点不够具体,我们用比较通俗的数学公式来描述这个过程: 问题提出:假设我们有一个3D空间中的一个点 XjX_{j},他可以被多个位于

XiaoZhuang 1万+

bundle adjustment算法学习

今天学习了稀疏的光束平差法,基于上一篇博文Levenberg–Marquardt算法学习,这里对学习内容做一个理论梳理。本次内容包括:BA简介BA迭代步长的数学推导稀疏BA迭代步长的算法求解过程1.BA简介   摄像机在静态环境中移动,得到不同时刻拍摄的多幅图像。假设这些图像是同一刚性物体的投影,则可由图像特征对应关系估计出摄像机的运动参数。在计算机视觉中 ,这一过程称为运动分析或由运动重建物体结

Where there is life, there is hope 2万+
上一篇: Latex使用过程中问题总结
下一篇: “photo wake-up”创新项目实训第一周开题总结
元宇宙MetaAI
博客等级 码龄10年 331粉丝 333原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值