Aimbot-PPO/Aimbot-PPO-Python/Tensorflow/PPOHistoryRecorder.py
Koha9 742529ccd7 Archive all tensorflow agents and env
archive all TF py&ipynb
turn face to pytorch.
2022-10-26 03:15:37 +09:00

38 lines
1.3 KiB
Python

import matplotlib.pyplot as plt
darkBlue = "#011627"
darkWhite = "#c9d2df"
class PPOHistory(object):
def __init__(self):
self.meanRewards = []
self.entropys = []
self.actorLosses = []
self.criticLosses = []
def saveHis(self, rewards, entropys, aLosses, cLosses):
self.meanRewards.extend([rewards])
self.entropys.extend([entropys])
self.actorLosses.extend(aLosses)
self.criticLosses.extend(cLosses)
def drawHis(self):
def setSubFig(subFig, data, title):
subFig.set_facecolor(darkBlue)
subFig.tick_params(colors=darkWhite)
subFig.spines["top"].set_color(darkWhite)
subFig.spines["bottom"].set_color(darkWhite)
subFig.spines["left"].set_color(darkWhite)
subFig.spines["right"].set_color(darkWhite)
subFig.plot(range(len(data)), data, color=darkWhite, label=title)
subFig.set_title(title, color=darkWhite)
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(21, 13), facecolor=darkBlue)
setSubFig(ax1, self.meanRewards, "meanRewards")
setSubFig(ax2, self.entropys, "entropys")
setSubFig(ax3, self.actorLosses, "actorLosses")
setSubFig(ax4, self.criticLosses, "criticLosses")
plt.show()