select.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_SELECT_HPP
13 #define MLPACK_METHODS_ANN_LAYER_SELECT_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
28 template <
29  typename InputDataType = arma::mat,
30  typename OutputDataType = arma::mat
31 >
32 class Select
33 {
34  public:
41  Select(const size_t index = 0, const size_t elements = 0);
42 
50  template<typename eT>
51  void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
52 
62  template<typename eT>
63  void Backward(const arma::Mat<eT>& /* input */,
64  const arma::Mat<eT>& gy,
65  arma::Mat<eT>& g);
66 
68  OutputDataType& OutputParameter() const { return outputParameter; }
70  OutputDataType& OutputParameter() { return outputParameter; }
71 
73  OutputDataType& Delta() const { return delta; }
75  OutputDataType& Delta() { return delta; }
76 
78  size_t const& Index() const { return index; }
79 
81  size_t const& NumElements() const { return elements; }
82 
86  template<typename Archive>
87  void serialize(Archive& ar, const uint32_t /* version */);
88 
89  private:
91  size_t index;
92 
94  size_t elements;
95 
97  OutputDataType delta;
98 
100  OutputDataType outputParameter;
101 }; // class Select
102 
103 } // namespace ann
104 } // namespace mlpack
105 
106 // Include implementation.
107 #include "select_impl.hpp"
108 
109 #endif
OutputDataType & Delta() const
Get the delta.
Definition: select.hpp:73
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: select.hpp:70
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
The select module selects the specified column from a given input matrix.
Definition: select.hpp:32
size_t const & NumElements() const
Get the number of elements selected.
Definition: select.hpp:81
Select(const size_t index=0, const size_t elements=0)
Create the Select object.
OutputDataType & Delta()
Modify the delta.
Definition: select.hpp:75
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: select.hpp:68
size_t const & Index() const
Get the column index.
Definition: select.hpp:78