data_dependent_random_initializer.hpp
Go to the documentation of this file.00001
00022 #ifndef __MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
00023 #define __MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
00024
00025 #include <mlpack/core.hpp>
00026
00027 namespace mlpack {
00028 namespace sparse_coding {
00029
00035 class DataDependentRandomInitializer
00036 {
00037 public:
00047 static void Initialize(const arma::mat& data,
00048 const size_t atoms,
00049 arma::mat& dictionary)
00050 {
00051
00052 dictionary.set_size(data.n_rows, atoms);
00053
00054
00055 for (size_t i = 0; i < atoms; ++i)
00056 {
00057
00058 dictionary.col(i) = (data.col(math::RandInt(data.n_cols)) +
00059 data.col(math::RandInt(data.n_cols)) +
00060 data.col(math::RandInt(data.n_cols)));
00061
00062
00063 dictionary.col(i) /= norm(dictionary.col(i), 2);
00064 }
00065 }
00066 };
00067
00068 };
00069 };
00070
00071 #endif