-
Notifications
You must be signed in to change notification settings - Fork 125
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
Better output if the optimization process gets terminated during the execution of an epoch. #180
Changes from all commits
e6b9075
4a02e40
db0b6f9
c6fe0dc
4561686
27be8d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,8 +132,8 @@ class ProgressBar | |
* @param objective Objective value of the current point. | ||
*/ | ||
template<typename OptimizerType, typename FunctionType, typename MatType> | ||
void StepTaken(OptimizerType& /* optimizer */, | ||
FunctionType& /* function */, | ||
void StepTaken(OptimizerType& optimizer, | ||
FunctionType& function, | ||
const MatType& /* coordinates */) | ||
{ | ||
if (newEpoch) | ||
|
@@ -164,8 +164,43 @@ class ProgressBar | |
output << "] " << progress << "% - ETA: " << (size_t) stepTimer.toc() * | ||
(epochSize - step + 1) % 60 << "s - loss: " << | ||
objective / (double) step << "\r"; | ||
output.flush(); | ||
|
||
if (optimizer.MaxIterations() < function.NumFunctions() && | ||
optimizer.MaxIterations() != 0) | ||
{ | ||
if (progress == (size_t)((double)(optimizer.MaxIterations()) / | ||
(double)(function.NumFunctions()) * 100) && | ||
(int)(steps * optimizer.BatchSize() - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @shrit I made a minor change in this line changing
and now also if
Let me know what you think of this approach. Thanks. |
||
optimizer.MaxIterations()) >= 0) | ||
{ | ||
const size_t progress = ((double) step / epochSize) * 100; | ||
output << step++ << "/" << epochSize << " ["; | ||
for (size_t i = 0; i < 100; i += width) | ||
{ | ||
if (i < progress) | ||
{ | ||
output << "="; | ||
} | ||
else if (i == progress) | ||
{ | ||
output << "|"; | ||
} | ||
else | ||
{ | ||
output << "x"; | ||
} | ||
} | ||
|
||
output << "] " << progress << "% - ETA: " << (size_t) stepTimer.toc() * | ||
(epochSize - step + 1) % 60 << "s - loss: " << | ||
objective / (double) step << "\r"; | ||
output << "\n" << "Optimization finished before the end of an epoch " | ||
<< "because of the entire dataset not being passed to " | ||
<< "the optimizer." << "\n" << "\r"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think that we could improve this error message? To a user I don't think it's clear what's going on. I think maybe something more like this could be clearer:
Also, why the |
||
} | ||
} | ||
|
||
output.flush(); | ||
stepTimer.tic(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
namespace ens { | ||
|
||
/** | ||
* CMA-ES - Covariance Matrix Adaptation Evolution Strategy is s a stochastic | ||
* CMA-ES - Covariance Matrix Adaptation Evolution Strategy is a stochastic | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, thanks! 👍 |
||
* search algorithm. CMA-ES is a second order approach estimating a positive | ||
* definite matrix within an iterative procedure using the covariance matrix. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this is the right way to check this condition. This will fail if the termination happens during the second epoch. Here's some example code:
If you try running that on this branch, you'll see:
(The
&& echo ""
is necessary because the last\r
is printed unnecessarily.)I wonder if we need to do this in a separate way, where a final call to this callback happens when the method terminates. Perhaps in the destructor of
ProgressBar
? I'm not sure if that could work, but it might.