From 8300eb3c3d7b1ca9c697cdccb4b420ec80bc63fe Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 16 May 2024 21:29:04 -0400 Subject: [PATCH] Fix example to print better output. --- doc/user/methods/sparse_coding.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/user/methods/sparse_coding.md b/doc/user/methods/sparse_coding.md index 7a98fc3320..ffdaa5c37b 100644 --- a/doc/user/methods/sparse_coding.md +++ b/doc/user/methods/sparse_coding.md @@ -13,15 +13,15 @@ dataset as a sparse combination of *atoms* in the dictionary. arma::mat data(40, 100, arma::fill::randu); arma::mat testData(40, 50, arma::fill::randu); -// Perform sparse coding with 20 atoms and an L1 penalty of 0.1. -mlpack::SparseCoding sc(20, 0.1); // Step 1: create object. +// Perform sparse coding with 20 atoms and an L1 penalty of 0.5. +mlpack::SparseCoding sc(20, 0.5); // Step 1: create object. double objective = sc.Train(data); // Step 2: learn dictionary. arma::mat codes; sc.Encode(testData, codes); // Step 3: encode new data. // Print some information about the test encoding. -std::cout << "Average sparsity of encoded test data: " - << 100.0 * arma::mean(arma::sum(codes != 0)) / codes.n_elem << "\%." +std::cout << "Average density of encoded test data: " + << 100.0 * arma::mean(arma::sum(codes != 0)) / codes.n_rows << "\%." << std::endl; ```

More examples...