src/mlpack/tests/cv_test.cpp
BOOST_AUTO_TEST_CASE(MSEMatResponsesTest)
{
  arma::mat data("1 2");
  arma::mat trainingResponses("1 2; 3 4");

  FFN<MeanSquaredError<>, ConstInitialization> ffn(MeanSquaredError<>(),
    ConstInitialization(0));
  ffn.Add<Linear<>>(1, 2);
  ffn.Add<IdentityLayer<>>();

  ens::RMSProp opt(0.2);
  opt.BatchSize() = 1;
  opt.Shuffle() = false;
  ffn.Train(data, trainingResponses, opt);

  // Making four responses that differ from the correct ones by 0, 1, 2 and 3
  // respectively
  arma::mat responses("1 3; 5 7");

  double expectedMSE = (0 * 0 + 1 * 1 + 2 * 2 + 3 * 3) / 4.0;

  BOOST_REQUIRE_CLOSE(MSE::Evaluate(ffn, data, responses), expectedMSE, 1e-1);
}
/**
 * Test the mean squared error with matrix responses.
 */
Test the mean squared error with matrix responses.
Test the mean squared error with matrix responses .
BOOST_AUTO_TEST_CASE(MSEMatResponsesTest)
{
  arma::mat data("1 2");
  arma::mat trainingResponses("1 2; 3 4");
  FFN<MeanSquaredError<>, ConstInitialization> ffn(MeanSquaredError<>(),
    ConstInitialization(0));
  ffn.Add<Linear<>>(1, 2);
  ffn.Add<IdentityLayer<>>();
  ens::RMSProp opt(0.2);
  opt.BatchSize() = 1;
  opt.Shuffle() = false;
  ffn.Train(data, trainingResponses, opt);
  arma::mat responses("1 3; 5 7");
  double expectedMSE = (0 * 0 + 1 * 1 + 2 * 2 + 3 * 3) / 4.0;
  BOOST_REQUIRE_CLOSE(MSE::Evaluate(ffn, data, responses), expectedMSE, 1e-1);
}
BOOST_AUTO_TEST_CASE ( MSEMatResponsesTest ) { arma :: mat data ( " " ) ; arma :: mat trainingResponses ( " " ) ; FFN < MeanSquaredError < > , ConstInitialization > ffn ( MeanSquaredError < > ( ) , ConstInitialization ( 0 ) ) ; ffn . Add < Linear < > > ( 1 , 2 ) ; ffn . Add < IdentityLayer < > > ( ) ; ens :: RMSProp opt ( 0.2 ) ; opt . BatchSize ( ) = 1 ; opt . Shuffle ( ) = false ; ffn . Train ( data , trainingResponses , opt ) ; arma :: mat responses ( " " ) ; double expectedMSE = ( 0 * 0 + 1 * 1 + 2 * 2 + 3 * 3 ) / 4.0 ; BOOST_REQUIRE_CLOSE ( MSE :: Evaluate ( ffn , data , responses ) , expectedMSE , 1e-1 ) ; }
Test the mean squared error with matrix responses.
Test the mean squared error with matrix responses .
// Making four responses that differ from the correct ones by 0, 1, 2 and 3 // respectively