Try to transform the kernel to a numpy array via a = a.numpy() and make sure you are passing this array with the expected shapes for plt.imshow, which is either [height, width, channels] or [height, width].