13 #ifndef MLPACK_METHODS_ANN_LAYER_ADD_MERGE_HPP 14 #define MLPACK_METHODS_ANN_LAYER_ADD_MERGE_HPP 18 #include "../visitor/delete_visitor.hpp" 19 #include "../visitor/delta_visitor.hpp" 20 #include "../visitor/output_parameter_visitor.hpp" 38 typename InputDataType = arma::mat,
39 typename OutputDataType = arma::mat,
40 typename... CustomLayers
51 AddMerge(
const bool model =
false,
const bool run =
true);
60 AddMerge(
const bool model,
const bool run,
const bool ownsLayers);
72 template<
typename InputType,
typename OutputType>
73 void Forward(
const InputType& , OutputType& output);
86 const arma::Mat<eT>& gy,
100 const arma::Mat<eT>& gy,
111 template<
typename eT>
112 void Gradient(
const arma::Mat<eT>& input,
113 const arma::Mat<eT>& error,
114 arma::Mat<eT>& gradient);
125 template<
typename eT>
126 void Gradient(
const arma::Mat<eT>& input,
127 const arma::Mat<eT>& error,
128 arma::Mat<eT>& gradient,
136 template <
class LayerType,
class... Args>
137 void Add(Args... args) { network.push_back(
new LayerType(args...)); }
144 void Add(LayerTypes<CustomLayers...> layer) { network.push_back(layer); }
157 OutputDataType
const&
Delta()
const {
return delta; }
159 OutputDataType&
Delta() {
return delta; }
162 std::vector<LayerTypes<CustomLayers...> >&
Model()
178 bool Run()
const {
return run; }
180 bool&
Run() {
return run; }
185 template<
typename Archive>
186 void serialize(Archive& ar,
const uint32_t );
201 std::vector<LayerTypes<CustomLayers...> > network;
204 std::vector<LayerTypes<CustomLayers...> > empty;
216 OutputDataType delta;
219 OutputDataType gradient;
222 InputDataType inputParameter;
225 OutputDataType outputParameter;
228 OutputDataType weights;
DeleteVisitor executes the destructor of the instantiated object.
Definition: delete_visitor.hpp:27
bool Run() const
Get the value of run parameter.
Definition: add_merge.hpp:178
bool & Run()
Modify the value of run parameter.
Definition: add_merge.hpp:180
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: add_merge.hpp:154
InputDataType & InputParameter()
Modify the input parameter.
Definition: add_merge.hpp:149
Implementation of the Add module class.
Definition: add.hpp:34
Implementation of the AddMerge module class.
Definition: add_merge.hpp:42
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...
Definition: add_merge_impl.hpp:81
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
OutputDataType & Delta()
Modify the delta.
Definition: add_merge.hpp:159
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & Delta() const
Get the delta.
Definition: add_merge.hpp:157
AddMerge(const bool model=false, const bool run=true)
Create the AddMerge object using the specified parameters.
Definition: add_merge_impl.hpp:28
OutputParameterVisitor exposes the output parameter of the given module.
Definition: output_parameter_visitor.hpp:27
OutputDataType const & Parameters() const
Get the parameters.
Definition: add_merge.hpp:173
OutputDataType & Parameters()
Modify the parameters.
Definition: add_merge.hpp:175
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: add_merge_impl.hpp:152
DeltaVisitor exposes the delta parameter of the given module.
Definition: delta_visitor.hpp:27
std::vector< LayerTypes< CustomLayers... > > & Model()
Return the model modules.
Definition: add_merge.hpp:162
~AddMerge()
Destructor to release allocated memory.
Definition: add_merge_impl.hpp:46
InputDataType const & InputParameter() const
Get the input parameter.
Definition: add_merge.hpp:147
void Forward(const InputType &, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: add_merge_impl.hpp:58
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: add_merge.hpp:152