Comments (5)
Both are fine. arma::get_cout_stream()
is probably best suited to "normal" and expected output, such as printing progress (eg. while executing an iterative algorithm). arma::get_cerr_stream()
is best suited for printing warnings and errors.
Alternatively, we can use cout
and cerr
directly.
In combination with either of the options above, it might be useful to adapt the simple printing approach used by armadillo. Internally, armadillo uses macros such as arma_debug_print
and arma_debug_warn
, which can be made inactive by the user by defining ARMA_DONT_PRINT_ERRORS
.
It's probably not a good idea to directly use arma_debug_print
and arma_debug_warn
, as these are internal functions. However, it would be easy to create analogues for ensmallen. For example, ens_debug_warn
, which would use optional defines such as ENS_DONT_PRINT_ERRORS
.
For all the gory details, see armadillo's debug.hpp
from ensmallen.
I think that maybe it might be a good idea here to emulate Armadillo's get_cout_stream()
and get_cerr_stream()
, so that we can do in some mlpack header, e.g.,
ens::set_cout_stream(Log::Info);
ens::set_cerr_stream(Log::Warn);
and then for any Log::Fatal
call we can just throw an exception.
I think that it won't be quite as simple as that; I'll try and find some time in the next day or two to think about if that will actually work. Something simple is good for now, but in the longer term this may also be related to mlpack#1481, where the user would pass some functor that would have some behavior when they wanted to print the loss or something like this.
from ensmallen.
Actually, looks like I wrote my comment too late. :) 71e6979 seems to handle most of this already. Still I'll think about how this can be hooked up more nicely to the mlpack infrastructure when desired. Maybe this?
#ifdef ENS_CUSTOM_INFO_LOG
Info = ENS_CUSTOM_INFO_LOG
#endif
#ifdef ENS_CUSTOM_WARN_LOG
Warn = ENS_CUSTOM_WARN_LOG
#endif
and then before including ensmallen, mlpack headers can just #define ENS_CUSTOM_INFO_LOG mlpack::Log::Info
and #define ENS_CUSTOM_WARN_LOG mlpack::Log::Warn
. (Also the mlpack header will have to first include the Log headers before including ensmallen, but that shouldn't be an issue---we can control that ordering.)
from ensmallen.
This issue seems resolved. Though, in the event future modification happen, please take note that for R to work we need the ability to redirect output / error away from cout
/ cerr
to Rcout
and Rcerr
, which maps internally to Rprintf
and REprintf
. The current setup that retrieves information from arma::get_cout_stream()
/arma::get_cerr_stream()
does allow for this.
References:
- R's printing note
- Relevant Rcpp portion handling redirects
from ensmallen.
@coatless: agreed. Right now the code just uses Armadillo's output streams so there should be no problem for Rcpp.
from ensmallen.
Related Issues (20)
- Compiling errors ensmallen 02.18.02 using VS2019 armadillo.lib 10.08.02 and mlpack.lib 03.04.02 HOT 6
- The example to use the constrained function HOT 4
- AugLagrangian with constraints validation HOT 8
- Multi-objective functions both MOEA/D-DE and NSGA2 - Examples using SchafferFunctionN1 HOT 1
- Implementing Function Type for Partial Derivatives HOT 3
- Does ensmallen work with armadillo >=10.0? HOT 5
- Enable HTTPS on ensmallen.org HOT 1
- Debian build (test) failure on i386 HOT 7
- ProgressBar() does not work with L_BFGS HOT 3
- Bounds for search space HOT 5
- During AugLagrangian's optimization, L_BFGS sets coordinates to nan HOT 6
- Migrate from Catch v2 to v3 HOT 3
- Using optimizer with integers HOT 6
- Custom early stop callback HOT 12
- SCD isn't stochastic and perhaps should be called CD? HOT 2
- 2.20 documentation + link issues
- Which optimizer should I use? HOT 2
- [PowerPC] Bus error during running tests: `KERN_PROTECTION_FAILURE at address: 0x00000000` HOT 7
- [aarch64] One test failure in Johnson844LovaszThetaFMatSDP HOT 8
- benchmarking framework for single-objective evolutionary optimization algorithms HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ensmallen.