a = numpy.array([[[0, 1, 2], [0, 0, 7], [9, 2, 0]], [[0, 0, 0], [1, 4, 6],
    [9, 0, 3]], [[1, 3, 2], [3, 4, 0], [1, 7, 9]]])
numpy.where(a != 0, 1, 0).sum()
Python Multidimensional Arrays - most efficient way to count number of non-zero entries