mirror of
https://github.com/wassname/rl_2d_walker.js.git
synced 2026-10-30 13:40:59 +08:00
410 KiB
410 KiB
In [149]:
%pylab inline
import pandas as pd
import os
import globPopulating the interactive namespace from numpy and matplotlib
In [150]:
from pylab import rcParams
rcParams['figure.figsize'] = 10, 4In [151]:
latest_log = sorted(glob.glob('../outputs/*.log'))[-2]
latest_logOut [151]:
'../outputs/train_2018-12-02_21-07-05.log'
In [ ]:
In [152]:
def parse_log(infile):
datas = []
data = {}
for line in open(infile).readlines():
if line.startswith('metric'):
_, name, val = line.strip('\n').split(' ', 2)
val = float(val)
if name=='episodeSteps':
steps=val
if len(data): datas.append(data)
data = {}
data[name] = val
df = pd.DataFrame(datas)
df = df.set_index('steps')
return dfIn [153]:
df = parse_log(latest_log)In [154]:
df['reward'].plot(style='.', title='reward')Out [154]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fbe8baefc88>
In [155]:
df[['head_height','center_y','mean_foot_height']].plot(style='.')Out [155]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fbe8b949dd8>
In [156]:
df[['center_x']].plot(style='.')Out [156]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fbe8b954cf8>
In [157]:
df['ActorLoss'].plot(style='.')
df['CriticLoss'].plot(style='.', secondary_y=True, ax=plt.gca())
plt.legend()Out [157]:
<matplotlib.legend.Legend at 0x7fbe8c98b588>
In [158]:
df[['head_height_reward']].plot(style='.')Out [158]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fbe8bb7cba8>
In [159]:
for col in df.columns:
df[col].plot(style='.', title=col)
plt.show()In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: