我有一个尺寸为(5,2,2)的NumPy数组,它是一系列2×2矩阵。我该如何询问这些2×2矩阵之一是否具有特定值?
例如,让我们看下面的系列
import numpy as np
zeros = np.zeros(4).reshape(2,2)
serie = np.array([zeros+1, zeros+2, zeros+3, zeros+4, zeros+5])
然后,在serie
中有一个2填充2的2×2矩阵。我如何询问serie
是否包含一个2填充的2×2矩阵并检索其索引?在这种情况下,索引将为1,因为serie[1,:]
是查找矩阵。