13 #ifndef MLPACK_METHODS_ANN_LAYER_MULTIPLY_MERGE_HPP 14 #define MLPACK_METHODS_ANN_LAYER_MULTIPLY_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 MultiplyMerge(
const bool model =
false,
const bool run =
true);
75 template<
typename InputType,
typename OutputType>
76 void Forward(
const InputType& , OutputType& output);
89 const arma::Mat<eT>& gy,
100 void Gradient(
const arma::Mat<eT>& input,
101 const arma::Mat<eT>& error,
102 arma::Mat<eT>& gradient);
109 template <
class LayerType,
class... Args>
110 void Add(Args... args) { network.push_back(
new LayerType(args...)); }
117 void Add(LayerTypes<CustomLayers...> layer) { network.push_back(layer); }
125 OutputDataType
const&
Delta()
const {
return delta; }
127 OutputDataType&
Delta() {
return delta; }
130 OutputDataType
const&
Gradient()
const {
return gradient; }
135 std::vector<LayerTypes<CustomLayers...> >&
Model()
156 template<
typename Archive>
157 void serialize(Archive& ar,
const uint32_t );
171 std::vector<LayerTypes<CustomLayers...> > network;
174 std::vector<LayerTypes<CustomLayers...> > empty;
186 OutputDataType delta;
189 OutputDataType gradient;
192 OutputDataType outputParameter;
195 OutputDataType weights;
DeleteVisitor executes the destructor of the instantiated object.
Definition: delete_visitor.hpp:27
OutputDataType const & Delta() const
Get the delta.
Definition: multiply_merge.hpp:125
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: multiply_merge.hpp:120
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Forward(const InputType &, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: multiply_merge_impl.hpp:109
MultiplyMerge & operator=(const MultiplyMerge &layer)
Copy assignment operator.
Definition: multiply_merge_impl.hpp:64
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: multiply_merge_impl.hpp:132
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: multiply_merge.hpp:122
OutputDataType const & Gradient() const
Get the gradient.
Definition: multiply_merge.hpp:130
OutputParameterVisitor exposes the output parameter of the given module.
Definition: output_parameter_visitor.hpp:27
OutputDataType & Delta()
Modify the delta.
Definition: multiply_merge.hpp:127
OutputDataType & Gradient()
Modify the gradient.
Definition: multiply_merge.hpp:132
std::vector< LayerTypes< CustomLayers... > > & Model()
Return the model modules.
Definition: multiply_merge.hpp:135
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: multiply_merge_impl.hpp:174
MultiplyMerge(const bool model=false, const bool run=true)
Create the MultiplyMerge object using the specified parameters.
Definition: multiply_merge_impl.hpp:28
size_t WeightSize() const
Get the size of the weights.
Definition: multiply_merge.hpp:151
OutputDataType const & Parameters() const
Get the parameters.
Definition: multiply_merge.hpp:146
DeltaVisitor exposes the delta parameter of the given module.
Definition: delta_visitor.hpp:27
OutputDataType & Parameters()
Modify the parameters.
Definition: multiply_merge.hpp:148
~MultiplyMerge()
Destructor to release allocated memory.
Definition: multiply_merge_impl.hpp:97