shape的功能是查看矩阵或者数组(array)的维数。
print(type(array([[[1.0,1.1]]]).shape))<class 'tuple'>
print(array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]]).shape)(4, 2)
print(array([[1.0,1.1],[1.0,1.0],[0,0]]).shape)
(3,2)
print(array([[1.0,1.1]]).shape)(1,2)
print(array([1.0,1.1]).shape)(2,)
print(array([[[1.0,1.1]]]).shape)(1, 1, 2)array.shape应该是array有几个维度,他就是几元组,元组中每个位置的值表示数组在该维度上的值个数
本文介绍了如何使用shape属性来查看数组的维度及其具体值。通过不同维度的数组实例演示了shape属性返回的是一个元组,元组的长度即为数组的维度数量,而元组中的每个值则代表了该维度上的元素个数。

被折叠的 条评论
为什么被折叠?



