13 #ifndef MLPACK_METHODS_ANN_LAYER_SOFTMAX_IMPL_HPP 14 #define MLPACK_METHODS_ANN_LAYER_SOFTMAX_IMPL_HPP 22 template<
typename InputDataType,
typename OutputDataType>
28 template<
typename InputDataType,
typename OutputDataType>
29 template<
typename InputType,
typename OutputType>
31 const InputType& input,
34 InputType softmaxInput = arma::exp(input.each_row() -
36 output = softmaxInput.each_row() / sum(softmaxInput, 0);
39 template<
typename InputDataType,
typename OutputDataType>
42 const arma::Mat<eT>& input,
43 const arma::Mat<eT>& gy,
46 g = input % (gy - arma::repmat(arma::sum(gy % input), input.n_rows, 1));
49 template<
typename InputDataType,
typename OutputDataType>
50 template<
typename Archive>
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: softmax_impl.hpp:41
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void serialize(Archive &, const uint32_t)
Serialize the layer.
Definition: softmax_impl.hpp:51
Softmax()
Create the Softmax object.
Definition: softmax_impl.hpp:23
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: softmax_impl.hpp:30