本文整理汇总了C++中arma::mat::randn方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::randn方法的具体用法?C++ mat::randn怎么用?C++ mat::randn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::mat
的用法示例。
在下文中一共展示了mat::randn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitializeWeights
void SoftmaxRegressionFunction::InitializeWeights(
arma::mat &weights,
const size_t featureSize,
const size_t numClasses,
const bool fitIntercept)
{
// Initialize values to 0.005 * r. 'r' is a matrix of random values taken from
// a Gaussian distribution with mean zero and variance one.
// If the fitIntercept flag is true, parameters.col(0) is the intercept.
if (fitIntercept)
weights.randn(numClasses, featureSize + 1);
else
weights.randn(numClasses, featureSize);
weights *= 0.005;
}
示例2: Initialize
/**
* Initialize the dictionary randomly from a normal distribution, such that
* each atom has a norm of 1. This is simple enough to be included with the
* definition.
*
* @param data Dataset to use for initialization.
* @param atoms Number of atoms (columns) in the dictionary.
* @param dictionary Dictionary to initialize.
*/
static void Initialize(const arma::mat& data,
const size_t atoms,
arma::mat& dictionary)
{
// Create random dictionary.
dictionary.randn(data.n_rows, atoms);
// Normalize each atom.
for (size_t j = 0; j < atoms; ++j)
dictionary.col(j) /= norm(dictionary.col(j), 2);
}