src/mlpack/tests/ann_layer_test.cpp
BOOST_AUTO_TEST_CASE(AlphaDropoutProbabilityTest)
{
  arma::mat input = arma::ones(1500, 1);
  const size_t iterations = 10;

  double probability[5] = { 0.1, 0.3, 0.4, 0.7, 0.8 };
  for (size_t trial = 0; trial < 5; ++trial)
  {
    double nonzeroCount = 0;
    for (size_t i = 0; i < iterations; ++i)
    {
      AlphaDropout<> module(probability[trial]);
      module.Deterministic() = false;

      arma::mat output;
      module.Forward(input, output);

      // Return a column vector containing the indices of elements of X
      // that are not alphaDash, we just need the number of
      // nonAlphaDash values.
      arma::uvec nonAlphaDash = arma::find(module.Mask());
      nonzeroCount += nonAlphaDash.n_elem;
    }

    const double expected = input.n_elem * (1-probability[trial]) * iterations;

    const double error = fabs(nonzeroCount - expected) / expected;

    BOOST_REQUIRE_LE(error, 0.15);
  }
}
/**
 * Perform AlphaDropout x times using ones as input, sum the number of ones
 * and validate that the layer is producing approximately the correct number
 * of ones.
 */
Perform AlphaDropout x times using ones as input, sum the number of ones
and validate that the layer is producing approximately the correct number
of ones.
Perform AlphaDropout x times using ones as input sum the number of ones and validate that the layer is producing approximately the correct number of ones .
BOOST_AUTO_TEST_CASE(AlphaDropoutProbabilityTest)
{
  arma::mat input = arma::ones(1500, 1);
  const size_t iterations = 10;
  double probability[5] = { 0.1, 0.3, 0.4, 0.7, 0.8 };
  for (size_t trial = 0; trial < 5; ++trial)
  {
    double nonzeroCount = 0;
    for (size_t i = 0; i < iterations; ++i)
    {
      AlphaDropout<> module(probability[trial]);
      module.Deterministic() = false;
      arma::mat output;
      module.Forward(input, output);
      arma::uvec nonAlphaDash = arma::find(module.Mask());
      nonzeroCount += nonAlphaDash.n_elem;
    }
    const double expected = input.n_elem * (1-probability[trial]) * iterations;
    const double error = fabs(nonzeroCount - expected) / expected;
    BOOST_REQUIRE_LE(error, 0.15);
  }
}
BOOST_AUTO_TEST_CASE ( AlphaDropoutProbabilityTest ) { arma :: mat input = arma :: ones ( 1500 , 1 ) ; const size_t iterations = 10 ; double probability [ 5 ] = { 0.1 , 0.3 , 0.4 , 0.7 , 0.8 } ; for ( size_t trial = 0 ; trial < 5 ; ++ trial ) { double nonzeroCount = 0 ; for ( size_t i = 0 ; i < iterations ; ++ i ) { AlphaDropout < > module ( probability [ trial ] ) ; module . Deterministic ( ) = false ; arma :: mat output ; module . Forward ( input , output ) ; arma :: uvec nonAlphaDash = arma :: find ( module . Mask ( ) ) ; nonzeroCount += nonAlphaDash . n_elem ; } const double expected = input . n_elem * ( 1 - probability [ trial ] ) * iterations ; const double error = fabs ( nonzeroCount - expected ) / expected ; BOOST_REQUIRE_LE ( error , 0.15 ) ; } }
Perform AlphaDropout x times using ones as input, sum the number of ones
 and validate that the layer is producing approximately the correct number
 of ones.
Perform AlphaDropout x times using ones as input sum the number of ones and validate that the layer is producing approximately the correct number of ones .
// Return a column vector containing the indices of elements of X // that are not alphaDash, we just need the number of // nonAlphaDash values.