本文整理汇总了C++中GMatrix::pseudoInverse方法的典型用法代码示例。如果您正苦于以下问题:C++ GMatrix::pseudoInverse方法的具体用法?C++ GMatrix::pseudoInverse怎么用?C++ GMatrix::pseudoInverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GMatrix
的用法示例。
在下文中一共展示了GMatrix::pseudoInverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pseudoInverse
void pseudoInverse(GArgReader& args)
{
GMatrix* pData = loadData(args.pop_string());
Holder<GMatrix> hData(pData);
GMatrix* pInverted = pData->pseudoInverse();
Holder<GMatrix> hInverted(pInverted);
pInverted->print(cout);
}
示例2: trainInnerInner
void GGaussianProcess::trainInnerInner(const GMatrix& features, const GMatrix& labels)
{
clear();
GMatrix* pL;
{
// Compute the kernel matrix
GMatrix k(features.rows(), features.rows());
for(size_t i = 0; i < features.rows(); i++)
{
GVec& row = k[i];
const GVec& a = features[i];
for(size_t j = 0; j < features.rows(); j++)
{
const GVec& b = features[j];
row[j] = m_weightsPriorVar * m_pKernel->apply(a, b);
}
}
// Add the noise variance to the diagonal of the kernel matrix
for(size_t i = 0; i < features.rows(); i++)
k[i][i] += m_noiseVar;
// Compute L
pL = k.cholesky(true);
}
std::unique_ptr<GMatrix> hL(pL);
// Compute the model
m_pLInv = pL->pseudoInverse();
GMatrix* pTmp = GMatrix::multiply(*m_pLInv, labels, false, false);
std::unique_ptr<GMatrix> hTmp(pTmp);
GMatrix* pLTrans = pL->transpose();
std::unique_ptr<GMatrix> hLTrans(pLTrans);
GMatrix* pLTransInv = pLTrans->pseudoInverse();
std::unique_ptr<GMatrix> hLTransInv(pLTransInv);
m_pAlpha = GMatrix::multiply(*pLTransInv, *pTmp, false, false);
GAssert(m_pAlpha->rows() == features.rows());
GAssert(m_pAlpha->cols() == labels.cols());
m_pStoredFeatures = new GMatrix();
m_pStoredFeatures->copy(&features);
}