Could someone please help me better understand the concept of “axis”? I often find it challenging to grasp the meaning of this term, and it makes me feel uncomfortable when I encounter it.

1 Like

Axis refers to the dimensions of a matrix.

Examples:

- A vector has only one dimension, or axis.
- A 2D matrix (like a flat monochrome image) has two axes.
- A 3D matrix (like a color image) has three axes.

1 Like

Right! So axis means the same thing as it does in analytic geometry. To use Tom’s third example of a color image, you can think of the first axis (axis = 0, because indexing in python is 0-based) as the vertical axis, the second axis is the horizontal axis and the third axis is the color axis.

Frequently we are dealing with a *batch* of images as input to our model and then they will be given to us as a 4D array or tensor, where the first axis (first dimension) is now the “samples” dimension: for each value of axis 0, we have one image with height, width and color axes.

1 Like