Example of the method for calculating the matrix of shape in Python: pythonshape
This document describes how to calculate the shape matrix in Python. We will share this with you for your reference. The details are as follows:
When I saw the machine learning algorithm, I noticed the shape calculation matrix method. Next, let's talk about my understanding.
>>> From numpy import * >>> import operator >>> a = mat ([[1, 2, 3], [5, 6, 9]) >>> amatrix ([[1, 2, 3], [5, 6, 9])
>>> Shape (a) (2, 3) >>>> a. shape [0] # calculate the number of rows 2 >>> a. shape [1] # calculate the number of Columns 3
Next is the explanation in Python.
Examples -------- >>> np. shape (np. eye (3) (3, 3) >>> np. shape ([[1, 2]) (1, 2)> np. shape ([0]) (1,) >>> np. shape (0) () >>> a = np. array ([(1, 2), (3, 4)], dtype = [('x', 'i4'), ('y ', 'i4')])> np. shape (a) (2,) >>>. shape (2 ,)