MLPACK
1.0.10
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
mlpack
methods
sparse_coding
random_initializer.hpp
Go to the documentation of this file.
1
23
#ifndef __MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP
24
#define __MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP
25
26
#include <
mlpack/core.hpp
>
27
28
namespace
mlpack {
29
namespace
sparse_coding {
30
35
class
RandomInitializer
36
{
37
public
:
47
static
void
Initialize
(
const
arma::mat& data,
48
const
size_t
atoms,
49
arma::mat& dictionary)
50
{
51
// Create random dictionary.
52
dictionary.randn(data.n_rows, atoms);
53
54
// Normalize each atom.
55
for
(
size_t
j = 0; j < atoms; ++j)
56
dictionary.col(j) /= norm(dictionary.col(j), 2);
57
}
58
};
59
60
};
// namespace sparse_coding
61
};
// namespace mlpack
62
63
#endif
Generated by
1.8.3.1