16 using namespace shark;
45 optimizer.
init(error);
46 for(
unsigned iter = 0; iter != 5000; ++iter)
48 optimizer.
step(error);
52 return loss(network(validation.
inputs()),validation.
labels());
79 double bestValidationError = 1e4;
80 double bestRegularization = 0;
81 for (
double regularization = 1.e-5; regularization < 1.e-3; regularization *= 2) {
83 for (std::size_t fold = 0; fold != folds.
size(); ++fold){
88 result +=
trainProblem(training, validation, regularization);
90 result /= folds.
size();
93 if (result < bestValidationError)
95 bestValidationError = result;
96 bestRegularization = regularization;
100 std::cout << regularization <<
" " << result << std::endl;
104 cout <<
"RESULTS: " << std::endl;
105 cout <<
"======== " << std::endl;
106 cout <<
"best validation error: " << bestValidationError << std::endl;
107 cout <<
"best regularization: " << bestRegularization<< std::endl;