- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试修改 ceres 的默认行为,即计算残差的平方和作为成本函数。我希望它只计算总和(残差已经以只能为正的方式计算)
根据文档,我应该使用 ConditionedCostFunction
这是我所做的:我定义了带有 1 个残差和 1 个参数的调节器
struct Conditioners : ceres::CostFunction
{
public:
Conditioners()
{
set_num_residuals(1);
mutable_parameter_block_sizes()->push_back(1);
}
~Conditioners()
{}
template<typename T>
T operator() (T x)
{
return T(x * x);
}
bool Evaluate(double const* const* parameters, double* residuals, double** jacobians) const
{
return true;
}
};
我把调节器放在一个 vector 中
std::vector<ceres::CostFunction*> conditioners;
for(int i = 0; i < 1; i++)
conditioners.push_back(new Conditioners());
ceres::ConditionedCostFunction* ccf =
new ceres::ConditionedCostFunction(cost_function, conditioners, ceres::TAKE_OWNERSHIP);
problem.AddResidualBlock(ccf, NULL, &x);
它编译和一切。但这并不能解决问题。它甚至没有开始。它说:
Ceres Solver Report: Iterations: 0, Initial cost: 4.512500e+01, Final cost: 4.512500e+01, Termination: CONVERGENCE
x : 0.5 -> 0.5
代替:
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 4.512500e+01 0.00e+00 9.50e+00 0.00e+00 0.00e+00 1.00e+04 0 2.99e-04 1.04e-03
1 4.511598e-07 4.51e+01 9.50e-04 9.50e+00 1.00e+00 3.00e+04 1 3.84e-04 9.72e-03
2 5.012552e-16 4.51e-07 3.17e-08 9.50e-04 1.00e+00 9.00e+04 1 2.98e-05 9.92e-03
Ceres Solver Report: Iterations: 2, Initial cost: 4.512500e+01, Final cost: 5.012552e-16, Termination: CONVERGENCE
x : 0.5 -> 10
(如果你想自己试试,这个例子修改了helloword example)您对出了什么问题有任何指示吗? (ceres 报告没有更具体)
最佳答案
我找到了解决方案,即:
struct Conditioners : ceres::CostFunction
{
public:
Conditioners()
{
set_num_residuals(1);
mutable_parameter_block_sizes()->push_back(1);
}
~Conditioners()
{}
template<typename T>
T operator() (T x)
{
return T(x * x);
}
bool Evaluate(double const* const* parameters, double* residuals, double** jacobians) const
{
residuals[0] = parameters[0][0] * parameters[0][0]
if (jacobians)
jacobians[0][0] = 2.0 * parameters[0][0]
return true;
}
};
我的错误是认为我只需要重新实现 () 运算符,ceres 就会自动找到 jacobian。它没有。
关于c++ - 修改平方和 [ceres-solver],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25574010/
打开几个编写宏/代码的示例,我突然被一个似乎安全的代码卡住了。求解器 (SOLVER.XLAM) 这是值得注意的,我想从我的系统中删除它。我想这不是一个相关的代码。谁能告诉我我应该怎么做?我已经安装了
是否可以使用 MSF api 将变量指定为半整数(V = 0 或 a = 5; Q1 = 5; Q2 10 * VPositive<= V <= 20 * VPositive ] ] 如果您使用
我正在研究线性和非线性编程(优化)框架的选项。 要求是: 支持大约线性和非线性规划问题。 100-1000 个变量和最多约 1000 个约束(我认为这很简单)。非线性问题具有涉及多个变量的乘法或除法的
SMT-Solver 可用于约束求解。众所周知,CSP 求解器也用于约束求解多年。那么 SMT 求解器与 CSP 求解器相比有什么优势呢? 最佳答案 这完全取决于你想做什么。您可以将两者都转换为 SA
我正在查看 Caffe LeNet 教程 here我想到了一个问题: 这两个代码有什么区别: self.solver.step(1) 和 self.solver.net.forward() # tr
我正在使用 CBC 求解器在 PyCharm 上解决优化问题,但一直遇到此错误: 错误:求解器 (cbc) 返回非零返回代码 (3221225781) 和 pyutilib.common._excep
我是 microsoft excels 求解器的用户,我很确定不可能求解最大化两个值。我想知道是否有人可能有另一种聪明的方法来做到这一点。 基本上,我有一列介于 1 到 30 之间的数字,我需要查看它
我想从数值的角度理解混合建模(特别是状态事件)背后的一般思想(尽管我不是数学家 :))。鉴于以下 Modelica 模型: model BouncingBall constant Real g
最近,我开始研究形式验证技术。在文献中,模型检查器和求解器可以以某种方式互换使用。 但是,模型检查器和求解器如何相互连接? p.s.如果建议提供一些论文或链接,我将不胜感激。 最佳答案 为了执行模型检
我希望这对某人来说是显而易见的。我只使用过 GLPK/MathProg。 我无法弄清楚 GNU MathProg(在 GLPK 内)中的语法来执行以下操作,例如: set PartsOfWeek; s
我有一个(对我来说)非常复杂的问题。我有两个向量: vectora <- c(111, 245, 379, 516, 671) vectorb <- c(38, 54, 62, 67, 108) 此外
我在 VBA 循环中使用 Excel 2007 中的内置求解器来解决许多不同的问题。有时,求解器会达到最大时间,这会导致出现弹出对话框,询问用户是否要继续、停止或结束。在所有情况下,我都希望它结束
我在 PC 上的 Excel 2010 中创建了一个程序,该程序依赖于 Excel 的内置求解器。我确保它适用于 PC 版 Excel 2010 和 Excel 2013。然后我尝试在 Excel 2
在汽车行业,当您购买汽车时,您有数千种不同的组件可供选择。并非每个组件都是可组合的,因此对于每辆汽车,都存在许多用命题逻辑表达的规则。就我而言,每辆车都有 2000 到 4000 条规则。 它们看起来
有没有办法让我们知道解算器中添加了多少约束?例如,我们初始化一个 z3 求解器 s = Solver(),然后使用 s.add() 添加约束。我们如何获得最终添加到求解器中的约束数量? 最佳答案 您可
我正在尝试修改 ceres 的默认行为,即计算残差的平方和作为成本函数。我希望它只计算总和(残差已经以只能为正的方式计算) 根据文档,我应该使用 ConditionedCostFunction 这是我
我有这个方法来求解根据增量返回 2 种类型数组的二次方程(如果小于零则有复数解) public static final String[] quadEquationSolver(double a, d
p = Int('p') q = Int('q') s = Solver() s.add(1<=p<=9, 1<=q<=19, 5<(3*p-4*q)<10) s.check() print s.mo
“问题”在标题中不应该是问题的情况。 我想为一组问题(类 Problem 的所有子项)实现一个求解器(类 Solver),这些问题或多或少共享同一组方法。我目前的设计是这样的: 在solver.h :
我为所有方向创建了一个单词求解器。它可以水平、垂直和反向查找单词。然而,我在让它走向各个方向时遇到了问题。所以把“你好”放在: H E i l x L p q c L O m 任何人
我是一名优秀的程序员,十分优秀!