So I only want to re-run code from this repo: https://github.com/dennybritz/reinforcement-learning/blob/master/MC/MC%20Prediction%20Solution.ipynb
My focus is on the print's part:
for i_episode in range(1, num_episodes + 1):
# Print out which episode we're on, useful for debugging.
if i_episode % 1000 == 0:
print "\rEpisode {}/{}.".format(i_episode, num_episodes)
sys.stdout.flush()
He is using sys.stdout.flush() to create a simple "progress" output. You can see the output from his repo it only show the last Episode iteration 10000/10000
because using sys.stdout.flush()
But when I try to run it in my jupyter notebook (I run using cmd command jupyter notebook
) I think sys.stdout.flush() not works, it show every printed iterations, not overwrite the previous one:
Episode 1000/10000.
Episode 2000/10000.
Episode 3000/10000.
Episode 4000/10000.
Episode 5000/10000.
Episode 6000/10000.
Episode 7000/10000.
Episode 8000/10000.
Episode 9000/10000.
Episode 10000/10000.
Am I missing something when run jupyter to make it works?