13 #ifndef MLPACK_METHODS_ANN_INIT_RULES_RANDOM_INIT_HPP 14 #define MLPACK_METHODS_ANN_INIT_RULES_RANDOM_INIT_HPP 35 const double upperBound = 1) :
36 lowerBound(lowerBound), upperBound(upperBound) { }
46 lowerBound(-
std::abs(bound)), upperBound(
std::abs(bound)) { }
56 void Initialize(arma::Mat<eT>& W,
const size_t rows,
const size_t cols)
59 W.set_size(rows, cols);
62 W *= (upperBound - lowerBound);
75 Log::Fatal <<
"Cannot initialize an empty matrix." << std::endl;
78 W *= (upperBound - lowerBound);
97 W.set_size(rows, cols, slices);
99 for (
size_t i = 0; i < slices; ++i)
108 template<
typename eT>
112 Log::Fatal <<
"Cannot initialize an empty cube." << std::endl;
114 for (
size_t i = 0; i < W.n_slices; ++i)
Linear algebra utility functions, generally performed on matrices or vectors.
This class is used to initialize randomly the weight matrix.
The core includes that mlpack expects; standard C++ includes and Armadillo.
RandomInitialization(const double lowerBound=-1, const double upperBound=1)
Initialize the random initialization rule with the given lower bound and upper bound.
void Initialize(arma::Cube< eT > &W)
Initialize randomly the elements of the specified weight 3rd order tensor.
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize randomly the elements of the specified weight matrix.
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
RandomInitialization(const double bound)
Initialize the random initialization rule with the given bound.
void Initialize(arma::Cube< eT > &W, const size_t rows, const size_t cols, const size_t slices)
Initialize randomly the elements of the specified weight 3rd order tensor.
void Initialize(arma::Mat< eT > &W)
Initialize randomly the elements of the specified weight matrix.