Learn how to deal with Numpy matrix dimensionality using np.reshape, np.newaxis and np.expand_dims, illustrated with Python code.
![Figure](https://www.kdnuggets.com/wp-content/uploads/abstract-fractal-header.jpg)
np.newaxis
- It is used to increase the dimension of the existing array. It uses the slicing operator to recreate the array.
- The dimension is temporarily added at the position of np.newaxis in the array. ‘None’ can also be used in place of np.newaxis.
np.reshape:
- It is used to reshape the array to the desired layout.
np.expand_dims:
- It expands the shape of an array by inserting a new axis at the axis position in the expanded array shape
Let’s see some primary applications where above NumPy dimension handling operations come in handy:
#2020 jul tutorials #overviews #numpy