12 #ifndef MLPACK_METHODS_ANN_LAYER_WEIGHTNORM_HPP 13 #define MLPACK_METHODS_ANN_LAYER_WEIGHTNORM_HPP 18 #include "../visitor/delete_visitor.hpp" 19 #include "../visitor/delta_visitor.hpp" 20 #include "../visitor/output_parameter_visitor.hpp" 21 #include "../visitor/reset_visitor.hpp" 22 #include "../visitor/weight_size_visitor.hpp" 23 #include "../visitor/weight_set_visitor.hpp" 57 typename InputDataType = arma::mat,
58 typename OutputDataType = arma::mat,
59 typename... CustomLayers
69 WeightNorm(LayerTypes<CustomLayers...> layer = LayerTypes<CustomLayers...>());
89 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
100 void Backward(
const arma::Mat<eT>& input,
101 const arma::Mat<eT>& gy,
112 template<
typename eT>
113 void Gradient(
const arma::Mat<eT>& input,
114 const arma::Mat<eT>& error,
115 arma::Mat<eT>& gradient);
118 OutputDataType
const&
Delta()
const {
return delta; }
120 OutputDataType&
Delta() {
return delta; }
123 OutputDataType
const&
Gradient()
const {
return gradient; }
138 LayerTypes<CustomLayers...>
const&
Layer() {
return wrappedLayer; }
143 template<
typename Archive>
144 void serialize(Archive& ar,
const uint32_t );
148 size_t biasWeightSize;
154 OutputDataType delta;
160 OutputDataType gradient;
163 LayerTypes<CustomLayers...> wrappedLayer;
166 size_t layerWeightSize;
169 OutputDataType outputParameter;
175 void ResetGradients(arma::mat& gradient);
181 OutputDataType scalarParameter;
184 OutputDataType vectorParameter;
187 OutputDataType weights;
193 OutputDataType layerGradients;
196 OutputDataType layerWeights;
DeleteVisitor executes the destructor of the instantiated object.
Definition: delete_visitor.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Reset()
Reset the layer parameters.
Definition: weight_norm_impl.hpp:49
~WeightNorm()
Destructor to release allocated memory.
Definition: weight_norm_impl.hpp:42
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Backward pass through the layer.
Definition: weight_norm_impl.hpp:88
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: weight_norm.hpp:128
WeightSizeVisitor returns the number of weights of the given module.
Definition: weight_size_visitor.hpp:27
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Forward pass of the WeightNorm layer.
Definition: weight_norm_impl.hpp:70
LayerTypes< CustomLayers... > const & Layer()
Get the wrapped layer.
Definition: weight_norm.hpp:138
WeightNorm(LayerTypes< CustomLayers... > layer=LayerTypes< CustomLayers... >())
Create the WeightNorm layer object.
Definition: weight_norm_impl.hpp:29
OutputDataType & Gradient()
Modify the gradient.
Definition: weight_norm.hpp:125
OutputDataType & Delta()
Modify the delta.
Definition: weight_norm.hpp:120
ResetVisitor executes the Reset() function.
Definition: reset_visitor.hpp:26
OutputParameterVisitor exposes the output parameter of the given module.
Definition: output_parameter_visitor.hpp:27
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: weight_norm_impl.hpp:144
OutputDataType const & Delta() const
Get the delta.
Definition: weight_norm.hpp:118
OutputDataType const & Parameters() const
Get the parameters.
Definition: weight_norm.hpp:133
OutputDataType & Parameters()
Modify the parameters.
Definition: weight_norm.hpp:135
DeltaVisitor exposes the delta parameter of the given module.
Definition: delta_visitor.hpp:27
OutputDataType const & Gradient() const
Get the gradient.
Definition: weight_norm.hpp:123
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: weight_norm.hpp:130