NumPy Error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

后端 未结 3 1079
心在旅途
心在旅途 2020-12-04 02:27

I am working on an Image Convolution code using numpy:

def CG(A, b, x, imax=10, epsilon = 0.01):
    steps=np.asarray(x)
    i = 0
    r = b - A * x
    d =          


        
3条回答
  •  死守一世寂寞
    2020-12-04 02:54

    delta_new is a matrix. Linear arithmetic comparison operations are not defined for matrices. You tried to compare a matrix of values to another matrix of values with a simple scalar comparison. Python doesn't know how to give you a single T/F result from this.

    I suspect that you want some scalar property on the matrices, such as determinant.

提交回复
热议问题