mlpack
3.1.1
src
mlpack
methods
sparse_coding
data_dependent_random_initializer.hpp
Go to the documentation of this file.
1
12
#ifndef MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
13
#define MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
14
15
#include <
mlpack/prereqs.hpp
>
16
#include <
mlpack/core/math/random.hpp
>
17
18
namespace
mlpack
{
19
namespace
sparse_coding {
20
26
class
DataDependentRandomInitializer
27
{
28
public
:
38
static
void
Initialize
(
const
arma::mat& data,
39
const
size_t
atoms,
40
arma::mat& dictionary)
41
{
42
// Set the size of the dictionary.
43
dictionary.set_size(data.n_rows, atoms);
44
45
// Create each atom.
46
for
(
size_t
i = 0; i < atoms; ++i)
47
{
48
// Add three atoms together.
49
dictionary.col(i) = (data.col(
math::RandInt
(data.n_cols)) +
50
data.col(
math::RandInt
(data.n_cols)) +
51
data.col(
math::RandInt
(data.n_cols)));
52
53
// Now normalize the atom.
54
dictionary.col(i) /= norm(dictionary.col(i), 2);
55
}
56
}
57
};
58
59
}
// namespace sparse_coding
60
}
// namespace mlpack
61
62
#endif
mlpack::sparse_coding::DataDependentRandomInitializer::Initialize
static void Initialize(const arma::mat &data, const size_t atoms, arma::mat &dictionary)
Initialize the dictionary by adding together three random observations from the data,...
Definition:
data_dependent_random_initializer.hpp:38
prereqs.hpp
random.hpp
mlpack
@serialization.hpp
Definition:
add_to_po.hpp:21
mlpack::math::RandInt
int RandInt(const int hiExclusive)
Generates a uniform random integer.
Definition:
random.hpp:105
mlpack::sparse_coding::DataDependentRandomInitializer
A data-dependent random dictionary initializer for SparseCoding.
Definition:
data_dependent_random_initializer.hpp:26
Generated by
1.8.17