2016-08-23 44 views
0

读取开源程序时,函数输出以下多维数组。输出被称为batchprint(batch)生成以下输出。为了准确地知道这个输出的结构。我试过print(batch.shape),它生成以下错误信息print(batch.shape) AttributeError: 'tuple' object has no attribute 'shape' 。理解这种类型的数组结构的结构/大小有哪些可能的方法?了解多维数组的大小和结构

enter image description here

+2

这不是一个多维数组。它是一个数组的元组。 – user2357112

+0

那么如何知道这个数组的元数据,比如大小和结构呢?谢谢。 – user288609

回答

0

元组,像一个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