mlpack  master
kathirvalavakumar_subavathi_init.hpp
Go to the documentation of this file.
1 
27 #ifndef MLPACK_METHODS_ANN_INIT_RULES_KATHIRVALAVAKUMAR_SUBAVATHI_INIT_HPP
28 #define MLPACK_METHODS_ANN_INIT_RULES_KATHIRVALAVAKUMAR_SUBAVATHI_INIT_HPP
29 
30 #include <mlpack/prereqs.hpp>
33 #include <iostream>
34 
35 namespace mlpack {
36 namespace ann {
37 
57 {
58  public:
65  template<typename eT>
66  KathirvalavakumarSubavathiInitialization(const arma::Mat<eT>& data,
67  const double s) : s(s)
68  {
69  dataSum = arma::sum(data % data);
70  }
71 
80  template<typename eT>
81  void Initialize(arma::Mat<eT>& W, const size_t rows, const size_t cols)
82  {
83  arma::Row<eT> b = s * arma::sqrt(3 / (rows * dataSum));
84  const double theta = b.min();
85  RandomInitialization randomInit(-theta, theta);
86  randomInit.Initialize(W, rows, cols);
87  }
88 
97  template<typename eT>
98  void Initialize(arma::Cube<eT>& W,
99  const size_t rows,
100  const size_t cols,
101  const size_t slices)
102  {
103  W = arma::Cube<eT>(rows, cols, slices);
104 
105  for (size_t i = 0; i < slices; i++)
106  Initialize(W.slice(i), rows, cols);
107  }
108 
109  private:
111  arma::rowvec dataSum;
112 
114  const double s;
115 }; // class KathirvalavakumarSubavathiInitialization
116 
117 
118 } // namespace ann
119 } // namespace mlpack
120 
121 #endif
KathirvalavakumarSubavathiInitialization(const arma::Mat< eT > &data, const double s)
Initialize the random initialization rule with the given values.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize the elements of the specified weight matrix with the Kathirvalavakumar-Subavathi method...
This class is used to initialize randomly the weight matrix.
Definition: random_init.hpp:24
The core includes that mlpack expects; standard C++ includes and Armadillo.
const double s
Parameter that defines the active region.
This class is used to initialize the weight matrix with the method proposed by T. ...
arma::rowvec dataSum
Parameter that defines the sum of elements in each column.
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 the Kathirvalavakumar-Subavathi...
void Initialize(arma::Mat< eT > &W, const size_t rows, const size_t cols)
Initialize randomly the elements of the specified weight matrix.
Definition: random_init.hpp:56