12 #ifndef MLPACK_METHODS_ANN_LAYER_SUBVIEW_HPP 13 #define MLPACK_METHODS_ANN_LAYER_SUBVIEW_HPP 31 typename InputDataType = arma::mat,
32 typename OutputDataType = arma::mat
48 const size_t beginRow = 0,
49 const size_t endRow = 0,
50 const size_t beginCol = 0,
51 const size_t endCol = 0) :
68 template<
typename InputType,
typename OutputType>
69 void Forward(InputType&& input, OutputType&& output)
71 size_t batchSize = input.n_cols / inSize;
74 endRow = ((endRow < input.n_rows) && (endRow >= beginRow))?
75 endRow : (input.n_rows - 1);
76 endCol = ((endCol < inSize) && (endCol >= beginCol)) ?
77 endCol : (inSize - 1);
80 (endRow - beginRow + 1) * (endCol - beginCol + 1), batchSize);
82 size_t batchBegin = beginCol;
83 size_t batchEnd = endCol;
86 if ((input.n_rows != ((endRow - beginRow + 1) *
87 (endCol - beginCol + 1))) || (input.n_cols != batchSize))
89 for (
size_t i = 0; i < batchSize; i++)
91 output.col(i) = arma::vectorise(
92 input.submat(beginRow, batchBegin, endRow, batchEnd));
114 template<
typename eT>
128 OutputDataType
const&
Delta()
const {
return delta; }
130 OutputDataType&
Delta() {
return delta; }
135 template<
typename Archive>
138 ar & BOOST_SERIALIZATION_NVP(inSize);
139 ar & BOOST_SERIALIZATION_NVP(beginRow);
140 ar & BOOST_SERIALIZATION_NVP(endRow);
141 ar & BOOST_SERIALIZATION_NVP(beginCol);
142 ar & BOOST_SERIALIZATION_NVP(endCol);
162 OutputDataType delta;
165 OutputDataType outputParameter;
OutputDataType & OutputParameter()
Modify the output parameter.
void Backward(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...
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
Implementation of the subview layer.
OutputDataType & Delta()
Modify the delta.
OutputDataType const & Delta() const
Get the delta.
Subview(const size_t inSize=1, const size_t beginRow=0, const size_t endRow=0, const size_t beginCol=0, const size_t endCol=0)
Create the Subview layer object using the specified range of input to accept.
void Forward(InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType const & OutputParameter() const
Get the output parameter.