Commands to run on debug mode in order to check if everything looks fine:

import matplotlib.pyplot as plt; import numpy as np; from menpo.image import Image k = 37; c = 1; n_ch = 3 l1 = 17 * 17 * n_ch; ind1 = np.arange(k * l1, (k+1) * l1, 1); ind2 = np.arange(k * l1 + c, (k+1) * l1, n_ch) Image(vec_i[ind1].reshape(17, 17, n_ch)).view(); plt.show() Image(vec_i[ind2].reshape(17, 17)).view(); plt.show() Image(e[ind1].reshape(17, 17, n_ch)).view(); plt.show() Image(e[ind2].reshape(17, 17)).view(); plt.show() dd = 1 Image(nabla_a[dd, c, k, :].reshape(17, 17)).view(); plt.show() Image(j[ind1, 0].reshape(17, 17, n_ch)).view(); plt.show() Image(j[ind2, 0].reshape(17, 17)).view(); plt.show()

In [ ]: