Last active
May 28, 2020 11:43
-
-
Save tdavchev/9d7014215693758f5c8a01a20422941b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
def smooth(scalars, weight): | |
last = scalars[0] | |
smoothed = list() | |
for point in scalars: | |
smoothed_val = last * weight + (1-weight)*point | |
smoothed.append(smoothed_val) | |
last = smoothed_val | |
return smoothed | |
def plot(names, labels, title, weight): | |
clrs = sns.color_palette("deep", len(labels)) | |
for i, name in enumerate(names): | |
data = np.genfromtxt(name, delimiter=',') | |
plt.plot(np.arange(len(data[1:, 2])), smooth(data[1:, 2], 0.0), alpha=0.2, color=clrs[i]) | |
plt.plot(np.arange(len(data[1:, 2])), smooth(data[1:, 2], weight), label=labels[i], color=clrs[i]) | |
plt.xlabel("Episodes") | |
plt.ylabel("Cost") | |
plt.legend() | |
plt.title("Number of environment steps required to converge.") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment