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
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>
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;
158 template<
typename Archive>
169 OutputDataType weights;
172 OutputDataType weight;
178 OutputDataType delta;
181 OutputDataType gradient;
184 InputDataType inputParameter;
187 OutputDataType outputParameter;
190 RegularizerType regularizer;
197#include "linear_impl.hpp"
Implementation of the Linear layer class.
Linear(const Linear &layer)
Copy constructor.
OutputDataType const & Delta() const
Get the delta.
Linear(const size_t inSize, const size_t outSize, RegularizerType regularizer=RegularizerType())
Create the Linear layer object using the specified number of units.
OutputDataType const & Parameters() const
Get the parameters.
Linear & operator=(Linear &&layer)
Move assignment operator.
OutputDataType const & Weight() const
Get the weight of the layer.
Linear(Linear &&)
Move constructor.
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 & Weight()
Modify the weight of the layer.
OutputDataType const & Bias() const
Get the bias of the layer.
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t InputSize() const
Get the input size.
Linear()
Create the Linear object.
size_t WeightSize() const
Get the size of the weights.
size_t OutputSize() const
Get the output size.
Linear & operator=(const Linear &layer)
Copy assignment operator.
void Gradient(const arma::Mat< eT > &input, const arma::Mat< eT > &error, arma::Mat< eT > &gradient)
OutputDataType const & Gradient() const
Get the gradient.
InputDataType const & InputParameter() const
Get the input parameter.
OutputDataType & Bias()
Modify the bias weights of the layer.
OutputDataType & Gradient()
Modify the gradient.
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...
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Parameters()
Modify the parameters.
OutputDataType & Delta()
Modify the delta.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.