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>
31 
32 #include "init_rules_traits.hpp"
33 #include "random_init.hpp"
34 
36 
37 #include <iostream>
38 
39 namespace mlpack {
40 namespace ann {
41 
61 {
62  public:
69  template<typename eT>
70  KathirvalavakumarSubavathiInitialization(const arma::Mat<eT>& data,
71  const double s) : s(s)
72  {
73  dataSum = arma::sum(data % data);
74  }
75 
84  template<typename eT>
85  void Initialize(arma::Mat<eT>& W, const size_t rows, const size_t cols)
86  {
87  arma::Row<eT> b = s * arma::sqrt(3 / (rows * dataSum));
88  const double theta = b.min();
89  RandomInitialization randomInit(-theta, theta);
90  randomInit.Initialize(W, rows, cols);
91  }
92 
102  template<typename eT>
103  void Initialize(arma::Cube<eT>& W,
104  const size_t rows,
105  const size_t cols,
106  const size_t slices)
107  {
108  W = arma::Cube<eT>(rows, cols, slices);
109 
110  for (size_t i = 0; i < slices; i++)
111  Initialize(W.slice(i), rows, cols);
112  }
113 
114  private:
116  arma::rowvec dataSum;
117 
119  double s;
120 }; // class KathirvalavakumarSubavathiInitialization
121 
123 template<>
125 {
126  public:
129  static const bool UseLayer = false;
130 };
131 
132 
133 } // namespace ann
134 } // namespace mlpack
135 
136 #endif
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 the elements of the specified weight matrix with the Kathirvalavakumar-Subavathi method...
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
KathirvalavakumarSubavathiInitialization(const arma::Mat< eT > &data, const double s)
Initialize the random initialization rule with the given values.
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.
This class is used to initialize the weight matrix with the method proposed by T. ...
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
This is a template class that can provide information about various initialization methods...