1. Conclusion:
# For a matrix X, X [:,:] This operation; # 1: represents all; # 2. count number from zero; # 3 may be a multi-dimensional, this test only to Three-dimensional. For more dimensions, please test yourself;
# 4. [1D, 2D, 3D ...]
2. Code:
import numpy as np X = np.array ([[0,1], [2,3], [4,5], [6,7], [8,9], [10,11], [12, 13], [14,15], [16,17], [18,19]]) # 10 * 2 matrix print (X) # X [row, column] count from 0 print (X [:, 0] ) #All rows and columns 0 print (X [0,0]) # 0 rows and 0 columns print (X [:, 1]) #All rows and column 0 print (X [1 ,:]) # 1 row All columns Print (X-[0: 2 ,:]) # 0 2-1 row to row, the column Y = [[[1,2], [3,4-], [5,6]], [[7,8], [9,10], [11,12]], [[13,14], [15,16], [17,18]]] # 3 * 3 * 2 matrix Y = np .array (y) print(of the type (the y-), of the type (the Y-)) Print (the Y-[0,0,0]) # We know that 3-dimensional coordinate system (x, y, z), I took this to speak! Counting from 0! It's (0,0,0), understand it! Print (the Y [0,0 ,:]) # is (0,0, all)
#output [[ 0 1] [ 2 3] [ 4 5] [ 6 7] [ 8 9] [10 11] [12 13] [14 15] [16 17] [18 19]] [ 0 2 4 6 8 10 12 14 16 18] 0 [ 1 3 5 7 9 11 13 15 17 19] [2 3] [[0 1] [2 3]] <class 'list'> <class 'numpy.ndarray'> 1 [1 2]
3. Reference URL:
https://blog.csdn.net/csj664103736/article/details/72828584/