In [10]:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [12]:
# Source: http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb
plt.rcParams['figure.figsize'] = (5, 5)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
def vis_square(data, padsize=1, padval=0):
data -= data.min()
data /= data.max()
# force the number of filters to be square
n = int(np.ceil(np.sqrt(data.shape[0])))
padding = ((0, n ** 2 - data.shape[0]), (0, padsize), (0, padsize)) + ((0, 0),) * (data.ndim - 3)
data = np.pad(data, padding, mode='constant', constant_values=(padval, padval))
# tile the filters into an image
data = data.reshape((n, n) + data.shape[1:]).transpose((0, 2, 1, 3) + tuple(range(4, data.ndim + 1)))
data = data.reshape((n * data.shape[1], n * data.shape[3]) + data.shape[4:])
plt.imshow(data)
In [ ]:
In [16]:
c1 = np.load("c1map.npy")
c2 = np.load("c2map.npy")
In [17]:
c1_proc = c1.transpose(0, 2, 3, 1)
vis_square(c1_proc)
In [21]:
vis_square(c2.reshape(32**2, 3, 3))
In [ ]:
c1.shape
In [ ]: