Closed kevinkovalchik closed 2 years ago
Hi Kevin,
Can you tell me more about your setup? Notably, do you use colab, notebook or is your program a python script?
Background
Training logs are printed in the standard error channel.
In a colab, model.fit()
will only print the keras progress bar. The training logs (the 145 lines you are mentioning) are normally not printed.
However, the training logs will be printed in the colab instance process (e.g. in the console if you run your own colab instance).
You can print the training logs in the notebook, by surrounding the fit
call with with sys_pipes():
(this is not what you want).
If you use a python script directly (i.e. you don't use colab), the logs are printed in the (only) console. There is currently no nice way to disable logging in the console, as passing --alsologtostderr=false only work if you use the C++ API.
A temporary solution is to hide the standard error during training (see this discussion).
Actions
Make sure fit
is not surrounded by with sys_pipes():
.
Disable the stderr. For example:
from contextlib import contextmanager,redirect_stderr,redirect_stdout
from os import devnull
@contextmanager
def suppress_stdout_stderr():
"""A context manager that redirects stdout and stderr to devnull"""
with open(devnull, 'w') as fnull:
with redirect_stderr(fnull) as err, redirect_stdout(fnull) as out:
yield (err, out)
with suppress_stdout_stderr():
model.fit(train_ds)
Thanks for the response. I am running things from the console, not colab or a notebook.
I did try to redirect the stderr to devnul without results, but I was changing sys.stderr directly. Using redirect_stderr with the context manager seems like a better, solution so I will try that, Also, I am using PyCharm, and their console sometimes seems to have some unexpected behavior at times, so if the above doesn't work I will try using the system console.
I'll let you know what happens,
I tried redirecting the stderr but the training logs are still being printed to the console, which seems strange. I can confirm that the stdout is being redirected, so it seems the stderr must be as well, but somehow the compiled code is bypassing this? This is happening in the PyCharm console and the system console.
Here's more information on my setup:
Noted. In this case, I'll expose logging control in the API. If all goes well, it will be part of the next release coming this month.
Cheers.
TLDR: The feature was added in TF-DF 0.2.2.
The amount of displayed training logs is controlled by verbose
model constructor or fit
argument. This parameter impacts both the training logs exported to the python's standard output and the C standard output and error.
verbose=0 => No logs. verbose=1 => High level training logs (default) verbose=2 => All the training logs
Hello,
I would like to be able to suppress the INFO logs that happen during training, but I have not been able to figure out how to do so. Setting
verbose=False
in the call tofit
simply removes a progress bar, but does not remove the 100+ lines of logging.For example:
For the model in question, there are 145 lines of this. The users of my code are generally biologists, and most of them will not understand nor want to see 145 lines of this, let alone see it multiple times if there is any optimization happening.
Is there a way to change the logging level here?
Thanks!
Best wishes, Kevin