In [ ]:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

%matplotlib inline

Run Experiment

Uncomment the following commands to run the experiments. Keep in mind that each experiment takes about 4h on a p2.xlarge machine. I do not recommend running from your laptop,


In [19]:
# !python sparse_dqn.py --sparse --timesteps 100000 --results_path results.sparse
# !python sparse_dqn.py --dense --timesteps 100000 --results_path results.dense

In [20]:
sparse = pd.read_csv('results.sparse/SeaquestDeterministic-v4.train.csv')
dense = pd.read_csv('results.dense/SeaquestDeterministic-v4.train.csv')

Values


In [21]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['values'])
fig.suptitle('Value Function (Sparse)', fontsize=16)
ax.legend()


Out[21]:
<matplotlib.legend.Legend at 0x121dd0b00>

In [22]:
sparse['values'].describe()


Out[22]:
count    100000.000000
mean          1.833002
std           0.772533
min           0.000000
25%           1.684198
50%           2.035855
75%           2.323535
max           2.727120
Name: values, dtype: float64

In [23]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(dense['values'])
fig.suptitle('Value Function (Dense)', fontsize=16)
ax.legend()


Out[23]:
<matplotlib.legend.Legend at 0x110216dd8>

In [24]:
dense['values'].describe()


Out[24]:
count    100000.000000
mean          1.996066
std           0.918295
min           0.000000
25%           1.620196
50%           2.272680
75%           2.728924
max           3.155729
Name: values, dtype: float64

In [25]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['values'].rolling(10000).mean(), label='sparse')
ax.plot(dense['values'].rolling(10000).mean(), label='dense')
fig.suptitle('Value Function (Dense vs Sparse)', fontsize=16)
ax.legend()


Out[25]:
<matplotlib.legend.Legend at 0x11b599358>

Score


In [26]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['score'])
fig.suptitle('Score (Sparse)', fontsize=16)
ax.legend()


Out[26]:
<matplotlib.legend.Legend at 0x11dd463c8>

In [27]:
sparse['score'].describe()


Out[27]:
count    100000.000000
mean         11.631200
std          20.890561
min           0.000000
25%           0.000000
50%           0.000000
75%          20.000000
max         140.000000
Name: score, dtype: float64

In [28]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(dense['score'])
fig.suptitle('Score (Dense)', fontsize=16)
ax.legend()


Out[28]:
<matplotlib.legend.Legend at 0x11ddcaf98>

In [29]:
dense['score'].describe()


Out[29]:
count    100000.000000
mean         11.190800
std          21.792539
min           0.000000
25%           0.000000
50%           0.000000
75%          20.000000
max         180.000000
Name: score, dtype: float64

In [30]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['score'].rolling(10000).mean(), label='sparse')
ax.plot(dense['score'].rolling(10000).mean(), label='dense')
fig.suptitle('Score (Dense vs Sparse)', fontsize=16)
ax.legend()


Out[30]:
<matplotlib.legend.Legend at 0x11de18828>

Loss


In [31]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['losses'])
fig.suptitle('Loss (Sparse)', fontsize=16)
ax.legend()


Out[31]:
<matplotlib.legend.Legend at 0x12200b278>

In [32]:
sparse['losses'].describe()


Out[32]:
count    90000.000000
mean         0.190537
std          0.333389
min          0.000006
25%          0.000168
50%          0.000369
75%          0.608106
max          2.493294
Name: losses, dtype: float64

In [33]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(dense['losses'])
fig.suptitle('Loss (Dense)', fontsize=16)
ax.legend()


Out[33]:
<matplotlib.legend.Legend at 0x125610a58>

In [34]:
dense['losses'].describe()


Out[34]:
count    90000.000000
mean         0.190884
std          0.332980
min          0.000012
25%          0.000269
50%          0.000591
75%          0.210502
max          3.044820
Name: losses, dtype: float64

In [35]:
fig, ax = plt.subplots(figsize=(20,5))
ax.plot(sparse['losses'].rolling(10000).mean(), label='sparse')
ax.plot(dense['losses'].rolling(10000).mean(), label='dense')
fig.suptitle('Loss (Dense vs Sparse)', fontsize=16)
ax.legend()


Out[35]:
<matplotlib.legend.Legend at 0x12a115b70>

In [ ]: