Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CNE test tolerances #360

Merged
merged 3 commits into from Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions HISTORY.md
@@ -1,14 +1,16 @@
### ensmallen ?.??.?: "???"
###### ????-??-??
* Fix CNE test tolerances
([#360](https://github.com/mlpack/ensmallen/pull/360)).

### ensmallen 2.19.1: "Eight Ball Deluxe"
###### 2023-01-30
* Avoid deprecation warnings in Armadillo 11.2+
* Avoid deprecation warnings in Armadillo 11.2+
([#347](https://github.com/mlpack/ensmallen/pull/347)).

### ensmallen 2.19.0: "Eight Ball Deluxe"
###### 2022-04-06
* Added DemonSGD and DemonAdam optimizers
* Added DemonSGD and DemonAdam optimizers
([#211](https://github.com/mlpack/ensmallen/pull/211)).

* Fix bug with Adam-like optimizers not resetting when `resetPolicy` is `true`.
Expand Down
17 changes: 13 additions & 4 deletions tests/cne_test.cpp
Expand Up @@ -96,11 +96,20 @@ TEST_CASE("CNEHimmelblauFunctionTest", "[CNETest]")
HimmelblauFunction f;
CNE optimizer(650, 3000, 0.3, 0.3, 0.3, 1e-7);

arma::mat coordinates = arma::mat("2; 1");
optimizer.Optimize(f, coordinates);
// Allow multiple trials.
arma::mat coordinates;
for (size_t trial = 0; trial < 3; ++trial)
{
coordinates = arma::mat("2; 1");
optimizer.Optimize(f, coordinates);

if (coordinates(0) == Approx(3.0).margin(0.6) &&
coordinates(1) == Approx(2.0).margin(0.2))
break;
}

REQUIRE(coordinates(0) == Approx(3.0).margin(0.1));
REQUIRE(coordinates(1) == Approx(2.0).margin(0.1));
REQUIRE(coordinates(0) == Approx(3.0).margin(0.6));
REQUIRE(coordinates(1) == Approx(2.0).margin(0.2));
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/main.cpp
Expand Up @@ -32,6 +32,7 @@ int main(int argc, char** argv)
// if the keyword 'time' is provided then the result of calling std::time(0)
// is used.
const size_t seed = session.config().rngSeed();
std::cout << "random seed: " << seed << std::endl;
srand((unsigned int) seed);
arma::arma_rng::set_seed(seed);

Expand Down