| 885 | |
| 886 | |
| 887 | def plot(): |
| 888 | import matplotlib |
| 889 | from matplotlib import pyplot as plt |
| 890 | |
| 891 | is_ipython = "inline" in matplotlib.get_backend() |
| 892 | if is_ipython: |
| 893 | from IPython import display |
| 894 | |
| 895 | with plt.ion(): |
| 896 | plt.figure(figsize=(10, 5)) |
| 897 | plt.subplot(1, 2, 1) |
| 898 | plt.plot(logs["return"]) |
| 899 | plt.title("returns") |
| 900 | plt.xlabel("iteration") |
| 901 | plt.subplot(1, 2, 2) |
| 902 | plt.plot(logs["last_reward"]) |
| 903 | plt.title("last reward") |
| 904 | plt.xlabel("iteration") |
| 905 | if is_ipython: |
| 906 | display.display(plt.gcf()) |
| 907 | display.clear_output(wait=True) |
| 908 | plt.show() |
| 909 | |
| 910 | |
| 911 | plot() |