mlpack
3.4.2
mlpack-3.4.2
src
mlpack
methods
sparse_coding
random_initializer.hpp
Go to the documentation of this file.
1
13
#ifndef MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP
14
#define MLPACK_METHODS_SPARSE_CODING_RANDOM_INITIALIZER_HPP
15
16
#include <
mlpack/prereqs.hpp
>
17
18
namespace
mlpack
{
19
namespace
sparse_coding {
20
25
class
RandomInitializer
26
{
27
public
:
37
static
void
Initialize
(
const
arma::mat& data,
38
const
size_t
atoms,
39
arma::mat& dictionary)
40
{
41
// Create random dictionary.
42
dictionary.randn(data.n_rows, atoms);
43
44
// Normalize each atom.
45
for
(
size_t
j = 0; j < atoms; ++j)
46
dictionary.col(j) /= norm(dictionary.col(j), 2);
47
}
48
};
49
50
}
// namespace sparse_coding
51
}
// namespace mlpack
52
53
#endif
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition:
add_to_cli11.hpp:21
mlpack::sparse_coding::RandomInitializer::Initialize
static void Initialize(const arma::mat &data, const size_t atoms, arma::mat &dictionary)
Initialize the dictionary randomly from a normal distribution, such that each atom has a norm of 1.
Definition:
random_initializer.hpp:37
mlpack::sparse_coding::RandomInitializer
A DictionaryInitializer for use with the SparseCoding class.
Definition:
random_initializer.hpp:26
Generated by
1.8.20