使用numpy.array
在使用shape
属性。
>>> import numpy as np
>>> X = np.array([
... [[-9.035250067710876], [7.453250169754028], [33.34074878692627]],
... [[-6.63700008392334], [5.132999956607819], [31.66075038909912]],
... [[-5.1272499561309814], [8.251499891281128], [30.925999641418457]]
... ])
>>> X.shape
(3L, 3L, 1L)
X.shape
为给定数组返回3个项目的元组;[n, T] = X.shape
加薪ValueError
。