Files
2018-12-20 07:05:33 +08:00

475 KiB

In [1]:
%pylab inline
import pandas as pd
import os
import glob
Populating the interactive namespace from numpy and matplotlib
In [2]:
from pylab import rcParams
rcParams['figure.figsize'] = 10, 4
In [3]:
latest_log = sorted(glob.glob('../outputs/*.log'))[-1]
latest_log
Out [3]:
'../outputs/train_2018-12-08_08-34-55.log'
In [ ]:
In [4]:
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 df
In [5]:
df = parse_log(latest_log)
In [6]:
df['reward'].plot(style='.', title='reward')
Out [6]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f516f97a518>
In [7]:
df[['head_height','center_y','mean_foot_height']].plot(style='.', ylim=[-2,2])
Out [7]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f516fa66198>
In [8]:
df[['center_x']].plot(style='.')
Out [8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f516f972390>
In [9]:
df['ActorLoss'].plot(style='.')
df['CriticLoss'].plot(style='.', secondary_y=True, ax=plt.gca())
plt.legend()
Out [9]:
<matplotlib.legend.Legend at 0x7f516fb6deb8>
In [10]:
df[['head_height_reward']].plot(style='.')
Out [10]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f516fb1b160>
In [11]:
for col in df.columns:
    df[col].plot(style='.', title=col)
    plt.show()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: