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.
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...
if(NOT PYTHON_EXECUTABLE OR NOT PY_DISTUTILS OR NOT PY_CYTHON OR NOT PY_NUMPY OR NOT PY_PANDAS) if(NOT PYTHON_EXECUTABLE OR NOT PY_DISTUTILS OR NOT PY_CYTHON OR NOT PY_NUMPY OR NOT PY_PANDAS) set(BINDING_SOURCES default_param.hpp default_param_impl.hpp generate_pyx.hpp generate_pyx.cpp get_arma_type.hpp get_cython_type.hpp get_numpy_type.hpp get_numpy_type_char.hpp get_param.hpp get_printable_param.hpp get_python_type.hpp import_decl.hpp print_class_defn.hpp print_defn.hpp print_doc.hpp print_doc_functions.hpp print_doc_functions_impl.hpp print_input_processing.hpp print_output_processing.hpp print_pyx.hpp print_pyx.cpp print_type_doc.hpp print_type_doc_impl.hpp py_option.hpp strip_type.hpp mlpack/arma_util.hpp setup.cfg copy_artifacts.py) set(CYTHON_SOURCES mlpack/arma_numpy.pxd mlpack/arma_numpy.pyx mlpack/arma.pxd mlpack/arma_util.hpp mlpack/io.pxd mlpack/io_util.hpp mlpack/matrix_utils.py mlpack/serialization.hpp mlpack/serialization.pxd) set(TEST_SOURCES tests/dataset_info_test.py tests/test_python_binding.py) get_property(CYTHON_INCLUDE_DIRECTORIES DIRECTORY $
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.