This article mainly introduces the shape calculation matrix method in Python, and involves implementation skills related to Python mathematical operations. if you need it, refer to the following article to introduce the shape calculation matrix method in Python, implementation skills related to Python mathematical operations. For more information, see
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 ,)
The above is the details of the python code example of the shape calculation matrix. For more information, see other related articles in the first PHP community!