12 #ifndef MLPACK_METHODS_ANN_LAYER_SOFTMIN_IMPL_HPP 13 #define MLPACK_METHODS_ANN_LAYER_SOFTMIN_IMPL_HPP 21 template<
typename InputDataType,
typename OutputDataType>
27 template<
typename InputDataType,
typename OutputDataType>
28 template<
typename InputType,
typename OutputType>
30 const InputType& input,
33 InputType softminInput = arma::exp(-(input.each_row() -
34 arma::min(input, 0)));
35 output = softminInput.each_row() / sum(softminInput, 0);
38 template<
typename InputDataType,
typename OutputDataType>
41 const arma::Mat<eT>& input,
42 const arma::Mat<eT>& gy,
45 g = input % (gy - arma::repmat(arma::sum(gy % input), input.n_rows, 1));
48 template<
typename InputDataType,
typename OutputDataType>
49 template<
typename Archive>
void serialize(Archive &, const uint32_t)
Serialize the layer.
Definition: softmin_impl.hpp:50
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
Definition: softmin_impl.hpp:29
void Backward(const arma::Mat< eT > &input, 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: softmin_impl.hpp:40
Softmin()
Create the Softmin object.
Definition: softmin_impl.hpp:22