sequential.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LAYER_SEQUENTIAL_HPP
14 #define MLPACK_METHODS_ANN_LAYER_SEQUENTIAL_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 #include "layer.hpp"
19 
20 namespace mlpack {
21 namespace ann {
22 
56 template <
57  typename InputType = arma::mat,
58  typename OutputType = arma::mat,
59  bool Residual = false
60 >
61 class SequentialType : public MultiLayer<InputType, OutputType>
62 {
63  public:
68 
75  SequentialType(const bool ownsLayers);
76 
78  SequentialType(const SequentialType& layer);
79 
82 
85 
87  SequentialType* Clone() const { return new SequentialType(*this); }
88 
96  void Forward(const InputType& input, OutputType& output);
97 
107  void Backward(const InputType& /* input */,
108  const OutputType& gy,
109  OutputType& g);
110 
118  void Gradient(const InputType& input,
119  const OutputType& error,
120  OutputType& /* gradient */);
121 
122  size_t InputShape() const;
123 
127  template<typename Archive>
128  void serialize(Archive& ar, const uint32_t /* version */);
129 
130  private:
132  bool reset;
133 
135  bool ownsLayers;
136 }; // class SequentialType
137 
138 // Standard Sequential layer.
140 
141 // Standard Residual layer.
143 
144 } // namespace ann
145 } // namespace mlpack
146 
147 // Include implementation.
148 #include "sequential_impl.hpp"
149 
150 #endif
~SequentialType()
Destroy the Sequential object.
SequentialType * Clone() const
Clone the SequentialType object. This handles polymorphism correctly.
Definition: sequential.hpp:87
Linear algebra utility functions, generally performed on matrices or vectors.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Implementation of the Sequential class.
Definition: sequential.hpp:61
The core includes that mlpack expects; standard C++ includes and Armadillo.
SequentialType()
Create the Sequential object.
void Backward(const InputType &, const OutputType &gy, OutputType &g)
Ordinary feed backward pass of a neural network, using 3rd-order tensors as input, calculating the function f(x) by propagating x backwards through f.
SequentialType< arma::mat, arma::mat, true > Residual
Definition: sequential.hpp:142
A "multi-layer" is a layer that is a wrapper around other layers.
Definition: multi_layer.hpp:34
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
SequentialType & operator=(const SequentialType &layer)
Copy assignment operator.
SequentialType< arma::mat, arma::mat, false > Sequential
Definition: sequential.hpp:139
void Gradient(const InputType &input, const OutputType &error, OutputType &)
Calculate the gradient using the output delta and the input activation.