def plot(episode, rewards, value_losses, policy_losses, noise): clear_output(True) rewards_x, rewards_smooth = smooth_plot(10, rewards, 500) value_losses_x, value_losses_smooth = smooth_plot(10, value_losses, 10000) policy_losses_x, policy_losses_smooth = smooth_plot( 10, policy_losses, 10000) noise_x, noise_smooth = smooth_plot(10, noise, 100) plt.figure(figsize=(18, 12)) plt.subplot(411) plt.title('episode %s. reward: %s' % (episode, rewards_smooth[-1])) plt.plot(rewards, label="Rewards", color='lightsteelblue', linewidth='1') plt.plot(rewards_x, rewards_smooth, label='Smothed_Rewards', color='darkorange', linewidth='3') plt.legend(loc='best') plt.subplot(412) plt.title('Value_Losses') plt.plot(value_losses, label="Value_Losses", color='lightsteelblue', linewidth='1') plt.plot(value_losses_x, value_losses_smooth, label="Smoothed_Value_Losses", color='darkorange', linewidth='3') plt.legend(loc='best') plt.subplot(413) plt.title('Policy_Losses') plt.plot(policy_losses, label="Policy_Losses", color='lightsteelblue', linewidth='1') plt.plot(policy_losses_x, policy_losses_smooth, label="Smoothed_Policy_Losses", color='darkorange', linewidth='3') plt.legend(loc='best') plt.subplot(414) plt.title('Noise') plt.plot(noise, label="Noise", color='lightsteelblue', linewidth='1') plt.plot(noise_x, noise_smooth, label="Smoothed_Noise", color='darkorange', linewidth='3') plt.legend(loc='best') plt.show()
def listS3Objects(bucket_name): s3 = boto3.resource('s3') bucket = s3.Bucket(bucket_name) s3_files = [] i = 0 for f in bucket.objects.all(): s3_files.append(f) i += 1 if i % 100 == 0: print(f) print('object #:', i) clear_output(wait=True) return s3_files
def plot_durations(): plt.figure(2) plt.clf() durations_t = torch.tensor(episode_durations, dtype=torch.float) plt.title('Training') plt.xlabel('Episode') plt.ylabel('Duration') plt.plot(durations_t.numpy()) if len(durations_t) >=100: means = duratoins_t.unfold(0,100,1).mean(1).view(-1) means = torch.cat((torch.zeros(99), means)) plt.plot(means.numpy()) plt.pause(0.001) if is_ipython: display.clear_output(wait=True) display.display(plt.gcf())
def plot_durations(): plt.figure(2) plt.clf() durations_t = torch.tensor(episode_durations, dtype=torch.float) plt.title('Training...') plt.xlabel('Episode') plt.ylabel('Duration') plt.plot(durations_t.numpy()) # Take 100 episode averages and plot them too if len(durations_t) >= 100: means = durations_t.unfold(0, 100, 1).mean(1).view(-1) means = torch.cat((torch.zeros(99), means)) plt.plot(means.numpy()) plt.pause(0.001) # pause a bit so that plots are updated if is_ipython: display.clear_output(wait=True) display.display(plt.gcf())