16 #ifndef MLPACK_METHODS_ANN_INIT_RULES_HE_INIT_HPP 17 #define MLPACK_METHODS_ANN_INIT_RULES_HE_INIT_HPP 64 template <
typename eT>
65 void Initialize(arma::Mat<eT>& W,
const size_t rows,
const size_t cols)
70 const double variance = 2.0 / (double) rows;
73 W.set_size(rows, cols);
77 W.imbue( [&]() {
return sqrt(variance) * arma::randn(); } );
86 template <
typename eT>
92 const double variance = 2.0 / (double) W.n_rows;
95 Log::Fatal <<
"Cannot initialize an empty matrix." << std::endl;
99 W.imbue( [&]() {
return sqrt(variance) * arma::randn(); } );
111 template <
typename eT>
118 W.set_size(rows, cols, slices);
120 for (
size_t i = 0; i < slices; ++i)
130 template <
typename eT>
134 Log::Fatal <<
"Cannot initialize an empty matrix" << std::endl;
136 for (
size_t i = 0; i < W.n_slices; ++i)
HeInitialization()
Initialize the HeInitialization object.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Initialize(arma::Cube< eT > &W)
Initialize the elements of the specified weight 3rd order tensor with He initialization rule...
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 He initialization rule...
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
This class is used to initialize weight matrix with the He initialization rule given by He et...
void Initialize(arma::Mat< eT > &W)
Initialize the elements of the weight matrix with the He initialization rule.
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize the elements of the weight matrix with the He initialization rule.
Miscellaneous math random-related routines.
if(NOT BUILD_GO_SHLIB) macro(add_go_binding name) endmacro() return() endif() endmacro() macro(post_go_setup) if(BUILD_GO_BINDINGS) file(APPEND "$