This article mainly introduces the method of shape computing matrix in Python, which involves the implementation of Python mathematical operations, and the need for a friend can refer to the following
This example describes the method of shape calculation matrix in Python. Share to everyone for your reference, as follows:
When you see the machine learning algorithm, you notice the shape calculation matrix. Now, 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] #计算行数2 >>> a.shape[1] #计算列数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 ')]) >>> n P.shape (a) (2,) >>> A.shape (2,)