This time I will bring you pythonHow to increase the matrix dimension, what are the precautions for increasing the matrix dimension in Python, the following is a practical case, let's take a look.
numpy.expand_dims(a, axis)
Examples
>>> x = np.array([1,2]) >>> x.shape (2,) >>> y = np.expand_dims(x, axis=0) >>> y array([[1, 2]]) >>> y.shape (1, 2) >>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis] >>> y array([[1], [2]]) >>> y.shape (2, 1)
I believe you read this article You have mastered the case method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Operation excel to read and write data
##How to perform automated unit testing with Python Unittest
The above is the detailed content of How to increase matrix dimension in python. For more information, please follow other related articles on the PHP Chinese website!