src/mlpack/tests/activation_functions_test.cpp
/**
 * Implementation of the PReLU activation function derivative test.
 * The function is implemented as PReLU layer in the file
 * parametric_relu.hpp
 *
 * @param input Input data used for evaluating the PReLU activation
 *   function.
 * @param target Target data used to evaluate the PReLU activation.
 */
Implementation of the PReLU activation function derivative test.
The function is implemented as PReLU layer in the file
parametric_relu.hpp

@param input Input data used for evaluating the PReLU activation
function.
@param target Target data used to evaluate the PReLU activation.
Implementation of the PReLU activation function derivative test . The function is implemented as PReLU layer in the file parametric_relu . hpp @param input Input data used for evaluating the PReLU activation function . @param target Target data used to evaluate the PReLU activation .
void CheckPReLUDerivativeCorrect(const arma::colvec input,
                                 const arma::colvec target)
{
  PReLU<> prelu;
  arma::colvec derivatives;
  arma::colvec error = arma::ones<arma::colvec>(input.n_elem);
  prelu.Backward(input, error, derivatives);
  for (size_t i = 0; i < derivatives.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(derivatives.at(i), target.at(i), 1e-3);
  }
}
void CheckPReLUDerivativeCorrect ( const arma :: colvec input , const arma :: colvec target ) { PReLU < > prelu ; arma :: colvec derivatives ; arma :: colvec error = arma :: ones < arma :: colvec > ( input . n_elem ) ; prelu . Backward ( input , error , derivatives ) ; for ( size_t i = 0 ; i < derivatives . n_elem ; i ++ ) { BOOST_REQUIRE_CLOSE ( derivatives . at ( i ) , target . at ( i ) , 1e-3 ) ; } }
Implementation of the PReLU activation function derivative test.
Implementation of the PReLU activation function derivative test .
// Test the calculation of the derivatives using the entire vector as input. // This error vector will be set to 1 to get the derivatives.