<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Goals of this notebook. Take our best model file
Step1:  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
Step2:  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.
Step3:  So most of the parameters are in the weight matrix for layer 6? That's probably not a good idea.
Receptive Fields/Kernels
Looking at the Kernels we've learnt using the script provided by Pylearn2.
<ASSISTANT_TASK:>
Python Code:
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
Explanation: Goals of this notebook. Take our best model file:
plot weights
look at number of parameters
...
End of explanation
cd ..
cat yaml_templates/alexnet_based_extra_convlayer.yaml
Explanation: 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:
End of explanation
settings = neukrill_net.utils.Settings("settings.json")
run_settings = neukrill_net.utils.load_run_settings(
    "run_settings/alexnet_based_40aug.json", settings, force=True)
model = pylearn2.utils.serial.load(run_settings["pickle abspath"])
params = model.get_params()
params[0].name
total_params = sum(map(lambda x: x.get_value().size,params))
print("Total parameters: {0}".format(total_params))
for l in params:
    print("Layer {0}: {1} parameters".format(l.name,l.get_value().size))
for l in params:
    print("Layer {0}: {1}% of the parameters.".format(l.name,
                        100*(float(l.get_value().size)/total_params)))
Explanation: 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.
End of explanation
%env PYLEARN2_VIEWER_COMMAND=/afs/inf.ed.ac.uk/user/s08/s0805516/repos/neukrill-net-work/image_hack.sh
%run ~/repos/pylearn2/pylearn2/scripts/show_weights.py /disk/scratch/neuroglycerin/models/continue_rep8aug_allrotations_recent.pkl
from IPython.display import Image
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()
%run ~/repos/pylearn2/pylearn2/scripts/show_weights.py /disk/scratch/neuroglycerin/models/replicate_8aug.pkl
plot_recent_pylearn2()
Explanation: So most of the parameters are in the weight matrix for layer 6? That's probably not a good idea.
Receptive Fields/Kernels
Looking at the Kernels we've learnt using the script provided by Pylearn2.
End of explanation
<END_TASK>