13 #ifndef MLPACK_METHODS_ANN_LAYER_LINEAR_HPP 14 #define MLPACK_METHODS_ANN_LAYER_LINEAR_HPP 34 typename InputDataType = arma::mat,
35 typename OutputDataType = arma::mat,
36 typename RegularizerType = NoRegularizer
51 Linear(
const size_t inSize,
53 RegularizerType regularizer = RegularizerType());
80 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
93 const arma::Mat<eT>& gy,
103 template<
typename eT>
104 void Gradient(
const arma::Mat<eT>& input,
105 const arma::Mat<eT>& error,
106 arma::Mat<eT>& gradient);
124 OutputDataType
const&
Delta()
const {
return delta; }
126 OutputDataType&
Delta() {
return delta; }
135 OutputDataType
const&
Gradient()
const {
return gradient; }
140 OutputDataType
const&
Weight()
const {
return weight; }
142 OutputDataType&
Weight() {
return weight; }
145 OutputDataType
const&
Bias()
const {
return bias; }
147 OutputDataType&
Bias() {
return bias; }
152 return (inSize * outSize) + outSize;
164 template<
typename Archive>
165 void serialize(Archive& ar,
const uint32_t );
175 OutputDataType weights;
178 OutputDataType weight;
184 OutputDataType delta;
187 OutputDataType gradient;
190 InputDataType inputParameter;
193 OutputDataType outputParameter;
196 RegularizerType regularizer;
203 #include "linear_impl.hpp" OutputDataType const & Delta() const
Get the delta.
size_t WeightSize() const
Get the size of the weights.
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType & Parameters()
Modify the parameters.
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...
size_t OutputSize() const
Get the output size.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & Bias()
Modify the bias weights of the layer.
Linear & operator=(const Linear &layer)
Copy assignment operator.
size_t InputShape() const
Get the shape of the input.
OutputDataType & Gradient()
Modify the gradient.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
OutputDataType const & Weight() const
Get the weight of the layer.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
OutputDataType const & Gradient() const
Get the gradient.
OutputDataType const & Bias() const
Get the bias of the layer.
OutputDataType const & Parameters() const
Get the parameters.
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t InputSize() const
Get the input size.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Weight()
Modify the weight of the layer.
OutputDataType & Delta()
Modify the delta.
Linear()
Create the Linear object.
InputDataType const & InputParameter() const
Get the input parameter.