What does the 0 stand for in mean3 = stacked_threes.mean(0)

Hi,
I think this image explains it the best:


You can imagine axis 0 is the height of stacking 6,131 of 28*28 2D matrix.
mean(0) will “collapse” this 3D matrix along 0 axis resulting in a single 2D 28*28 matrix which each pixel is the mean of all the 6,131 in its location (i.e. location [0][0] is mean of 6,131 location [0][0])
The image was taken from this blog:
https://www.awesomegrasp.com/what-is-python-numpy-array-dimension-or-axis/
There is also the code for this matrix, my recommendation is to follow Jeremy’s advice and just play with this example (try mean 0, mean 1, mean -1 etc…) and check the results matching your manual calculations.
You can even try with 4D but you cannot draw that so nicely and probably will get a headache :slight_smile:

1 Like