我正在尝试学习如何将稀疏编码算法与 mlpack 库一起使用。当我在我的 mlpack::sparse_coding:SparseCoding 实例上调用 Encode() 时,出现错误
[WARN] There are 63 inactive atoms. They will be reinitialized randomly.
error: solve(): solution not found
仅仅是算法无法学习数据的潜在表示吗?或者也许这是我的用法?相关部分如下编辑:修改了一行以修复不相关的错误,但原始错误仍然存在。
double* Application::GetSparseCodes(arma::mat* trainingExample, int atomCount)
{
double* latentRep = new double[atomCount];
mlpack::sparse_coding::SparseCoding<mlpack::sparse_coding::DataDependentRandomInitializer> sc(*trainingExample, Utils::ATOM_COUNT, 1.0);
sc.Encode(Utils::MAX_ITERATIONS);
arma::mat& latentRepMat = sc.Codes();
for (int i = 0; i < atomCount; i++)
latentRep[i] = latentRepMat.at(i, 0);
return latentRep;
}
一些相关参数
const static int IMAGE_WIDTH = 20;
const static int IMAGE_HEIGHT = 20;
const static int PIXEL_COUNT = IMAGE_WIDTH * IMAGE_HEIGHT;
const static int ATOM_COUNT = 64;
const static int MAX_ITERATIONS = 100000;