Goals of this notebook. Take our best model file:
In [1]:
    
import pylearn2.utils
import pylearn2.config
import theano
import neukrill_net.dense_dataset
import neukrill_net.utils
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import holoviews as hl
%load_ext holoviews.ipython
import sklearn.metrics
    
    
    
    
    
    
At the time of writing our best model is defined by the run settings file alexnet_based_40aug.json, basically taking the AlexNet based architecture with an extra convolutional layer and using more augmentation. Full details are in the following YAML file:
In [2]:
    
cd ..
    
    
In [4]:
    
cat yaml_templates/alexnet_based_extra_convlayer.yaml
    
    
It has relatively few MLP layers, so maybe we should look at where the parameters in our model are distributed; comparing the MLP layers to the convolutional ones.
In [7]:
    
settings = neukrill_net.utils.Settings("settings.json")
run_settings = neukrill_net.utils.load_run_settings(
    "run_settings/alexnet_based_40aug.json", settings, force=True)
    
In [8]:
    
model = pylearn2.utils.serial.load(run_settings["pickle abspath"])
    
In [9]:
    
params = model.get_params()
    
In [14]:
    
params[0].name
    
    Out[14]:
In [25]:
    
total_params = sum(map(lambda x: x.get_value().size,params))
print("Total parameters: {0}".format(total_params))
    
    
In [16]:
    
for l in params:
    print("Layer {0}: {1} parameters".format(l.name,l.get_value().size))
    
    
In [19]:
    
for l in params:
    print("Layer {0}: {1}% of the parameters.".format(l.name,
                        100*(float(l.get_value().size)/total_params)))
    
    
So most of the parameters are in the weight matrix for layer 6? That's probably not a good idea.
In [6]:
    
%env PYLEARN2_VIEWER_COMMAND=/afs/inf.ed.ac.uk/user/s08/s0805516/repos/neukrill-net-work/image_hack.sh
    
    
In [16]:
    
%run ~/repos/pylearn2/pylearn2/scripts/show_weights.py /disk/scratch/neuroglycerin/models/continue_rep8aug_allrotations_recent.pkl
    
    
In [17]:
    
from IPython.display import Image
    
In [18]:
    
def plot_recent_pylearn2():
    pl2plt = Image(filename="/afs/inf.ed.ac.uk/user/s08/s0805516/tmp/pylearnplot.png", width=500)
    return pl2plt
plot_recent_pylearn2()
    
    Out[18]:
In [23]:
    
%run ~/repos/pylearn2/pylearn2/scripts/show_weights.py /disk/scratch/neuroglycerin/models/replicate_8aug.pkl
    
    
In [24]:
    
plot_recent_pylearn2()
    
    Out[24]:
I think that's just the weights from the kernels in the first layer. The script is not specific about it though.