15 #ifndef MLPACK_METHODS_ANN_INIT_RULES_LECUN_NORMAL_INIT_HPP 16 #define MLPACK_METHODS_ANN_INIT_RULES_LECUN_NORMAL_INIT_HPP 68 template <
typename eT>
76 const double variance = 1.0 / ((double) rows);
79 W.set_size(rows, cols);
83 W.imbue( [&]() {
return sqrt(variance) * arma::randn(); } );
92 template <
typename eT>
98 const double variance = 1.0 / (double) W.n_rows;
101 Log::Fatal <<
"Cannot initialize an empty matrix." << std::endl;
105 W.imbue( [&]() {
return sqrt(variance) * arma::randn(); } );
117 template <
typename eT>
124 W.set_size(rows, cols, slices);
126 for (
size_t i = 0; i < slices; ++i)
136 template <
typename eT>
140 Log::Fatal <<
"Cannot initialize an empty cube." << std::endl;
142 for (
size_t i = 0; i < W.n_slices; ++i)
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition: log.hpp:90
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
LecunNormalInitialization()
Initialize the LecunNormalInitialization object.
Definition: lecun_normal_init.hpp:55
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class is used to initialize weight matrix with the Lecun Normalization initialization rule...
Definition: lecun_normal_init.hpp:49
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize the elements of the weight matrix with the Lecun Normal initialization rule...
Definition: lecun_normal_init.hpp:69
void Initialize(arma::Mat< eT > &W)
Initialize the elements of the weight matrix with the Lecun Normal initialization rule...
Definition: lecun_normal_init.hpp:93
void Initialize(arma::Cube< eT > &W, const size_t rows, const size_t cols, const size_t slices)
Initialize the elements of the specified weight 3rd order tensor with Lecun Normal initialization rul...
Definition: lecun_normal_init.hpp:118
void Initialize(arma::Cube< eT > &W)
Initialize the elements of the specified weight 3rd order tensor with Lecun Normal initialization rul...
Definition: lecun_normal_init.hpp:137
Miscellaneous math random-related routines.