# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

# +
import pickle
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns;
sns.set()
from utils import load_dataset



# +
flatten = True
dataset = 'mnist'

(x_train, y_train), (x_test, y_test) = load_dataset(dataset, flatten)

with open('weights.pickle','rb') as f:
    weights = pickle.load(f)

with open('test.pickle','rb') as f:
        intermediate_test_outputs = pickle.load(f)
with open('train.pickle','rb') as f:
    intermediate_train_outputs = pickle.load(f)

# -

#fig, ax = plt.subplots()
#ax = sns.heatmap(weights[1][0])
#fig.savefig('temp.pdf')
len(intermediate_train_outputs[0])

for sample_no in xrange((len(intermediate_train_outputs[0]))):
    if sample_no%100==0: print(sample_no)
    fig, axn = plt.subplots(2,2,sharex=True, sharey=True)
    for i,ax in enumerate(axn.flat):
        if i==0:
            sns.heatmap(x_train[sample_no].reshape(28,28), ax= ax)
            #ax.imshow(x_train[sample_no].reshape(28,28))
        elif i == 1:
            sns.heatmap(intermediate_train_outputs[0][sample_no].reshape((28,28)), ax=ax)
        elif i == 2:
            sns.heatmap(intermediate_train_outputs[1][sample_no].reshape((28,28)), ax=ax)
        else:
            sns.heatmap(y_train[sample_no].reshape((28,28)), ax=ax)
    fig.savefig('train/' + str(sample_no) +'.png')
    plt.cla()





StarcoderdataJupyterScriptsDedupFiltered