MLPACK
1.0.4
|
00001 00023 #ifndef __MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP 00024 #define __MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP 00025 00026 #include <mlpack/core.hpp> 00027 00028 namespace mlpack { 00029 namespace sparse_coding { 00030 00035 class RandomInitializer 00036 { 00037 public: 00047 static void Initialize(const arma::mat& data, 00048 const size_t atoms, 00049 arma::mat& dictionary) 00050 { 00051 // Create random dictionary. 00052 dictionary.randn(data.n_rows, atoms); 00053 00054 // Normalize each atom. 00055 for (size_t j = 0; j < atoms; ++j) 00056 dictionary.col(j) /= norm(dictionary.col(j), 2); 00057 } 00058 }; 00059 00060 }; // namespace sparse_coding 00061 }; // namespace mlpack 00062 00063 #endif