My class includes a call to load data and to train a (deep learning) model; in-between, I have print
statements for logging purposes:
get_data() -> print() -> train() -> print()
Fitting set 5... (Loss,Acc) = (0.512,0.921)
Fitting set
is printed after get_data()
, and Loss,Acc
after train()
- however, adding an additional print
statement within get_data()
, as below, modifies the output log as follows:
def get_data():
t0=time()
data = load_data(path)
print(time()-t0,'sec')
return data
Fitting set 5... (Loss,Acc) = (0.512,0.921) 2.486 sec
The time log is printed after train()
, despite being called before. Further, the time log is printed immediately after the Loss,Acc
log, rather than in '2.etc' secs - so it isn't a call order issue.
How do I force Python to
print
when it's asked to, rather than later?