facebookresearch / PyTorch-BigGraph

Generate embeddings from large-scale graph-structured data.
https://torchbiggraph.readthedocs.io/
Other
3.37k stars 448 forks source link

log file generation #169

Open Bin-Go2 opened 3 years ago

Bin-Go2 commented 3 years ago

Hi, I check the codes and find that the progress and some statistics logged to the console by default, I am wondering if I can include these logs into a log file and choose whether let them display on the terminal. Thank you.

lw commented 3 years ago

I don't think there's any out-of-the-box options to do that, but one approach to do this is to create your own "entry point", by copying the current one which lives in the train.py file and change it in two ways: reduce the verbosity of the logging (for example by only logging at lever warning or above), and pass a stats_handler argument to the constructor of the TrainingCoordinator (see here), instead of leaving it to its default. The stats_handler must be an object that exposes a on_stats method that gets called once every bucket is trained, with the same stats that are logged (see here the full interface). In there you can log to file or do whatever you want. If I remember correctly it has one difference compared to the logging: the stats handler is only invoked on trainer 0, and it's invoked also for the buckets that were trainer in other workers. This is supposed to make it easier to collect all stats in a single place.

Bin-Go2 commented 3 years ago

Thanks for your suggestion, I will try to do it.