0

I was running a program, and it will output the progress bar to a file train.2.log. Here's a link to the file train.2.log, which looks like the following on terminal :

This is line 1

Training ...

This is line 2

epoch       iteration   main/loss   main/loss_ctc  main/loss_att ...

This is line 3

0           100         455.209     899.082        264.978 ...

There are no problems when u were to call head -n3 train.2.log, it shows the first 3 lines very well, but in the text file its not human-readable, because of the binaries <0x1b> that are written within it (see train.2.log).

Question : How do i modify the file such that it becomes human readable ?

Usually progress bars are written such that \r is used instead of \n, following this question. Hence i tried this solution, which did not work as the program that i called doesn't seem to be using \r.

leonardltk1
  • 257
  • 1
  • 4
  • 18
  • can you turn off the progress feature of the program creating train.2.log? OTherwise, we'll need to see a small set of sample log file, the required output from that same sample, any code, current output or error messages you have. Please add this information to the body of your question using the `{}` tool from the edit menu on mouse-selected text to have correctly formatted `data/output/code/errMsgs`. Good luck. – shellter Apr 01 '20 at 22:49
  • Try the "strings" command. – Frank Merrow Apr 02 '20 at 00:34

1 Answers1

1

The problem seems to be that you output both training progress & it's log to the same output stream. If you got the train.2.log by redirecting the Python output to a file in terminal (app.py > train.log), but still want to observe it's progress, then I'd suggest printing the log to a separate stream, like stderr.

You can achieve that in Python with print("Log message", file=sys.stderr), then redirect program output:

app.py 2>train.log

This way app.py will print the progress bar to stdout as usual, while the training log is available on stderr without progress indication mixed in.

x1n13y84issmd42
  • 890
  • 9
  • 17