本文整理汇总了C++中table::offset方法的典型用法代码示例。如果您正苦于以下问题:C++ table::offset方法的具体用法?C++ table::offset怎么用?C++ table::offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table
的用法示例。
在下文中一共展示了table::offset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_gradient
/**
* Adds the gradient of the expected log-likelihood of the specified
* data point to the gradient table g.
*
* \param phead the distribution over a leading set of indices of f
* \param tail a fixed assignment to the remaining indices of f
* \param w the weight of the data point
*/
void add_gradient(const table<T>& phead, const uint_vector& tail, T w,
table<T>& g) const {
assert(phead.arity() + tail.size() == g.arity());
std::size_t index = g.offset().linear(tail, phead.arity());
for (std::size_t i = 0; i < phead.size(); ++i) {
g[index + i] += phead[i] * w;
}
}
示例2: add_hessian_diag
/**
* Adds the diagonal of the Hessia of the expected log-likelihoood of
* the specified data point to the Hessian diagonal h.
*/
void add_hessian_diag(const table<T>& phead, const uint_vector& tail, T w,
table<T>& h) const {
assert(phead.arity() + tail.size() == h.arity());
std::size_t index = h.offset().linear(tail, phead.arity());
for (std::size_t i = 0; i < phead.size(); ++i) {
h[index + i] -= phead[i] * w / (f[index + i] * f[index + i]);
}
}