const_init.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_ANN_INIT_RULES_CONST_INIT_HPP
15 #define MLPACK_METHODS_ANN_INIT_RULES_CONST_INIT_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace ann {
21 
26 {
27  public:
31  ConstInitialization(const double initVal = 0) : initVal(initVal)
32  { /* Nothing to do here */ }
33 
41  template<typename eT>
42  void Initialize(arma::Mat<eT>& W, const size_t rows, const size_t cols)
43  {
44  W.set_size(rows, cols);
45  W.fill(initVal);
46  }
47 
56  template<typename eT>
57  void Initialize(arma::Cube<eT>& W,
58  const size_t rows,
59  const size_t cols,
60  const size_t slices)
61  {
62  W.set_size(rows, cols, slices);
63  W.fill(initVal);
64  }
65 
67  double const& InitValue() const { return initVal; }
69  double& initValue() { return initVal; }
70 
71  private:
73  double initVal;
74 }; // class ConstInitialization
75 
76 } // namespace ann
77 } // namespace mlpack
78 
79 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize the elements of the specified weight matrix.
Definition: const_init.hpp:42
ConstInitialization(const double initVal=0)
Create the ConstantInitialization object.
Definition: const_init.hpp:31
double const & InitValue() const
Get the initialization value.
Definition: const_init.hpp:67
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).
Definition: const_init.hpp:57
This class is used to initialize weight matrix with constant values.
Definition: const_init.hpp:25
double & initValue()
Modify the initialization value.
Definition: const_init.hpp:69