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;
OutputDataType const & Gradient() const
Get the gradient.
Definition: linear.hpp:135
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & Weight()
Modify the weight of the layer.
Definition: linear.hpp:142
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: linear_impl.hpp:146
size_t WeightSize() const
Get the size of the weights.
Definition: linear.hpp:150
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: linear_impl.hpp:122
OutputDataType const & Weight() const
Get the weight of the layer.
Definition: linear.hpp:140
OutputDataType const & Delta() const
Get the delta.
Definition: linear.hpp:124
InputDataType const & InputParameter() const
Get the input parameter.
Definition: linear.hpp:114
OutputDataType & Gradient()
Modify the gradient.
Definition: linear.hpp:137
Linear()
Create the Linear object.
Definition: linear_impl.hpp:24
OutputDataType & Delta()
Modify the delta.
Definition: linear.hpp:126
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: linear.hpp:121
OutputDataType const & Bias() const
Get the bias of the layer.
Definition: linear.hpp:145
size_t InputSize() const
Get the input size.
Definition: linear.hpp:129
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...
Definition: linear_impl.hpp:112
OutputDataType & Bias()
Modify the bias weights of the layer.
Definition: linear.hpp:147
OutputDataType const & Parameters() const
Get the parameters.
Definition: linear.hpp:109
InputDataType & InputParameter()
Modify the input parameter.
Definition: linear.hpp:116
size_t OutputSize() const
Get the output size.
Definition: linear.hpp:132
size_t InputShape() const
Get the shape of the input.
Definition: linear.hpp:156
Linear & operator=(const Linear &layer)
Copy assignment operator.
Definition: linear_impl.hpp:72
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: linear.hpp:119
OutputDataType & Parameters()
Modify the parameters.
Definition: linear.hpp:111