本文整理汇总了C++中matrix::Matrix::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::size方法的具体用法?C++ Matrix::size怎么用?C++ Matrix::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix::Matrix
的用法示例。
在下文中一共展示了Matrix::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: standardize
matrix::Matrix standardize(const matrix::Matrix& input)
{
auto means = apply(reduce(input, {1}, matrix::Add()), matrix::Divide(input.size()[1]));
auto inputMeanSubtracted = broadcast(input, means, {1}, matrix::Subtract());
auto stddevs = apply(reduce(apply(inputMeanSubtracted,
matrix::SquareAndScale(1.0 / input.size()[1])), {1}, matrix::Add()), matrix::Sqrt());
std::cout << stddevs.toString();
return broadcast(inputMeanSubtracted, stddevs, {1}, matrix::Divide());
}
示例2: compare
void compare(const matrix::Matrix& predictions, const matrix::Matrix& reference)
{
size_t samples = predictions.size()[1];
auto differences = apply(predictions, reference, matrix::Subtract());
auto squareDifferences = apply(differences, matrix::Square());
auto normalizedSquareDifferences = apply(squareDifferences, matrix::Divide(samples));
double cost = std::sqrt(reduce(normalizedSquareDifferences, {}, matrix::Add())[0]);
std::cout << "Total RMS error was " << cost << "\n";
if(cost < 15.0)
{
std::cout << "Test Passed\n";
}
else
{
std::cout << "Test Failed\n";
}
}