mlpack  master
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, 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  arma::Mat<eT>&& gy,
65  arma::Mat<eT>&& g);
66 
68  InputDataType& InputParameter() const { return inputParameter; }
70  InputDataType& InputParameter() { return inputParameter; }
71 
73  OutputDataType& OutputParameter() const { return outputParameter; }
75  OutputDataType& OutputParameter() { return outputParameter; }
76 
78  OutputDataType& Delta() const { return delta; }
80  OutputDataType& Delta() { return delta; }
81 
85  template<typename Archive>
86  void Serialize(Archive& ar, const unsigned int /* version */);
87 
88  private:
90  size_t index;
91 
93  size_t elements;
94 
96  OutputDataType delta;
97 
99  InputDataType inputParameter;
100 
102  OutputDataType outputParameter;
103 }; // class Select
104 
105 } // namespace ann
106 } // namespace mlpack
107 
108 // Include implementation.
109 #include "select_impl.hpp"
110 
111 #endif
InputDataType & InputParameter()
Modify the input parameter.
Definition: select.hpp:70
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
size_t index
Locally-stored column index.
Definition: select.hpp:90
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: select.hpp:75
Select(const size_t index, const size_t elements=0)
Create the Select object.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The select module selects the specified column from a given input matrix.
Definition: select.hpp:32
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: select.hpp:73
OutputDataType & Delta()
Modify the delta.
Definition: select.hpp:80
void Serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType outputParameter
Locally-stored output parameter object.
Definition: select.hpp:102
InputDataType inputParameter
Locally-stored input parameter object.
Definition: select.hpp:99
OutputDataType & Delta() const
Get the delta.
Definition: select.hpp:78
size_t elements
Locally-stored number of elements selected.
Definition: select.hpp:93
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...
void Backward(const arma::Mat< eT > &&, 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...
OutputDataType delta
Locally-stored delta object.
Definition: select.hpp:96
InputDataType & InputParameter() const
Get the input parameter.
Definition: select.hpp:68