As shown below:
>>> import numpy as np >>> x = ([1, 2]) >>> y = ([[1],[2]]) >>> z = ([[1,2]]) >>> print() (2,) >>> print() (2, 1) >>> print() (1, 2)
x[1,2] has the shape value (2,), meaning a one-dimensional array with 2 elements in the array
The shape value of y[[1],[2]] is (2,1), meaning a two-dimensional array with 1 element per row
z The shape value of [[1,2]] is (1, 2), meaning a two-dimensional array with 2 elements per row
Above this talk about the difference between shape( ,) and ( ,1) in python is all that I have shared with you, I hope it can give you a reference, and I hope you can support me more.