对于给定的2个维数组,例如下面,我需要检查所有元素是否小于0.2。
a = np.array([[0.26002, 0.13918, 0.6008 ],
[0.2997 , 0.28646, 0.41384],
[0.41614, 0.36464, 0.21922]])
这是我基于this question的代码。
res = abs(a<0.2)
all(i==True for i in res)
但是代码抱怨
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()