MLPACK
1.0.7
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
mlpack
methods
sparse_coding
data_dependent_random_initializer.hpp
Go to the documentation of this file.
1
22
#ifndef __MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
23
#define __MLPACK_METHODS_SPARSE_CODING_DATA_DEPENDENT_RANDOM_INITIALIZER_HPP
24
25
#include <
mlpack/core.hpp
>
26
27
namespace
mlpack {
28
namespace
sparse_coding {
29
35
class
DataDependentRandomInitializer
36
{
37
public
:
47
static
void
Initialize
(
const
arma::mat& data,
48
const
size_t
atoms,
49
arma::mat& dictionary)
50
{
51
// Set the size of the dictionary.
52
dictionary.set_size(data.n_rows, atoms);
53
54
// Create each atom.
55
for
(
size_t
i = 0; i < atoms; ++i)
56
{
57
// Add three atoms together.
58
dictionary.col(i) = (data.col(
math::RandInt
(data.n_cols)) +
59
data.col(
math::RandInt
(data.n_cols)) +
60
data.col(
math::RandInt
(data.n_cols)));
61
62
// Now normalize the atom.
63
dictionary.col(i) /= norm(dictionary.col(i), 2);
64
}
65
}
66
};
67
68
};
// namespace sparse_coding
69
};
// namespace mlpack
70
71
#endif
Generated by
1.8.3.1