13 #ifndef MLPACK_METHODS_ANN_LAYER_LINEAR_NO_BIAS_IMPL_HPP 14 #define MLPACK_METHODS_ANN_LAYER_LINEAR_NO_BIAS_IMPL_HPP 22 template<
typename InputDataType,
typename OutputDataType,
23 typename RegularizerType>
31 template<
typename InputDataType,
typename OutputDataType,
32 typename RegularizerType>
36 RegularizerType regularizer) :
39 regularizer(regularizer)
44 template<
typename InputDataType,
typename OutputDataType,
45 typename RegularizerType>
48 weight = arma::mat(weights.memptr(), outSize, inSize,
false,
false);
51 template<
typename InputDataType,
typename OutputDataType,
52 typename RegularizerType>
55 const arma::Mat<eT>& input, arma::Mat<eT>& output)
57 output = weight * input;
60 template<
typename InputDataType,
typename OutputDataType,
61 typename RegularizerType>
64 const arma::Mat<eT>& ,
const arma::Mat<eT>& gy, arma::Mat<eT>& g)
69 template<
typename InputDataType,
typename OutputDataType,
70 typename RegularizerType>
73 const arma::Mat<eT>& input,
74 const arma::Mat<eT>& error,
75 arma::Mat<eT>& gradient)
77 gradient.submat(0, 0, weight.n_elem - 1, 0) = arma::vectorise(
79 regularizer.Evaluate(weights, gradient);
82 template<
typename InputDataType,
typename OutputDataType,
83 typename RegularizerType>
84 template<
typename Archive>
86 Archive& ar,
const uint32_t )
88 ar(CEREAL_NVP(inSize));
89 ar(CEREAL_NVP(outSize));
93 if (cereal::is_loading<Archive>())
94 weights.set_size(outSize * inSize, 1);
LinearNoBias()
Create the LinearNoBias object.
Definition: linear_no_bias_impl.hpp:24
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: linear_no_bias_impl.hpp:85
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
size_t WeightSize() const
Get the size of the weights.
Definition: linear_no_bias.hpp:127
OutputDataType const & Gradient() const
Get the gradient.
Definition: linear_no_bias.hpp:122
Implementation of the LinearNoBias class.
Definition: layer_types.hpp:103
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_no_bias_impl.hpp:63
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_no_bias_impl.hpp:54