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

cd ..

settings = neukrill_net.utils.Settings("settings.json")
run_settings = neukrill_net.utils.load_run_settings(
    "run_settings/8aug_flat_lr.json", settings, force=True)

model = pylearn2.utils.serial.load(run_settings['alt_picklepath'])

%run check_test_score.py run_settings/8aug_flat_lr.json

%run check_test_score.py run_settings/alexnet_based_norm_global_8aug.json

"""
Explanation: Comparing the performance of our best model without modulation of the learning rate or momentum, deactivating the extensions.
End of explanation
"""


run_settings = neukrill_net.utils.load_run_settings(
    "run_settings/alexnet_based_norm_global_8aug.json", settings, force=True)
old = pylearn2.utils.serial.load(run_settings['pickle abspath'])

def plot_monitor(model,c = 'valid_y_nll'):
    channel = model.monitor.channels[c]
    plt.title(c)
    plt.plot(channel.example_record,channel.val_record)
    return None

plot_monitor(old)

plot_monitor(model)

plot_monitor(old, c="train_y_nll")

plot_monitor(model, c="train_y_nll")

"""
Explanation: So in the end it reaches almost the same log loss. I'm guessing it probably does this much faster?
End of explanation
"""


