src/mlpack/tests/activation_functions_test.cpp
void CheckCELUDerivativeCorrect(const arma::colvec input,
                                const arma::colvec target)
{
  // Initialize CELU object with alpha = 1.0.
  CELU<> lrf(1.0);

  // Test the calculation of the derivatives using the entire vector as input.
  arma::colvec derivatives, activations;

  // This error vector will be set to 1 to get the derivatives.
  arma::colvec error = arma::ones<arma::colvec>(input.n_elem);
  lrf.Forward(input, activations);
  lrf.Backward(activations, 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 CELU activation function derivative test. The function
 * is implemented as CELU layer in the file celu.hpp.
 *
 * @param input Input data used for evaluating the CELU activation function.
 * @param target Target data used to evaluate the CELU activation.
 */
Implementation of the CELU activation function derivative test. The function
is implemented as CELU layer in the file celu.hpp.

@param input Input data used for evaluating the CELU activation function.
@param target Target data used to evaluate the CELU activation.
Implementation of the CELU activation function derivative test . The function is implemented as CELU layer in the file celu . hpp . @param input Input data used for evaluating the CELU activation function . @param target Target data used to evaluate the CELU activation .
void CheckCELUDerivativeCorrect(const arma::colvec input,
                                const arma::colvec target)
{
  CELU<> lrf(1.0);
  arma::colvec derivatives, activations;
  arma::colvec error = arma::ones<arma::colvec>(input.n_elem);
  lrf.Forward(input, activations);
  lrf.Backward(activations, error, derivatives);
  for (size_t i = 0; i < derivatives.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(derivatives.at(i), target.at(i), 1e-3);
  }
}
void CheckCELUDerivativeCorrect ( const arma :: colvec input , const arma :: colvec target ) { CELU < > lrf ( 1.0 ) ; arma :: colvec derivatives , activations ; arma :: colvec error = arma :: ones < arma :: colvec > ( input . n_elem ) ; lrf . Forward ( input , activations ) ; lrf . Backward ( activations , 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 CELU activation function derivative test.
Implementation of the CELU activation function derivative test .
// Initialize CELU object with alpha = 1.0. // Test the calculation of the derivatives using the entire vector as input. // This error vector will be set to 1 to get the derivatives.