繁体   English   中英

了解多维数组的大小和结构

[英]understanding the size and structure of multi-dimensional array

读取开源程序时,函数将输出以下多维数组。 输出称为batch print(batch)生成以下输出。 为了确切地知道此输出的结构。 我尝试了print(batch.shape) ,它生成以下错误消息print(batch.shape) AttributeError: 'tuple' object has no attribute 'shape' 有什么可能的方法来了解这种类型的数组结构的结构/大小?

在此处输入图片说明

元组(如Python列表)具有len属性

len(batch)   # probably gives 2

您可以通过迭代查看元组元素的属性

for arr in batch:
   print(arr.shape)
   print(arr.dtype)

要么

 [arr.shape for arr in batch]

要么

 batch[0].shape
 batch[1].shape

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM