CVXOPT QP Solver: TypeError: 'A' must be a 'd' matrix with 1000 columns

后端 未结 3 1577
深忆病人
深忆病人 2021-01-17 20:20

I\'m trying to use the CVXOPT qp solver to compute the Lagrange Multipliers for a Support Vector Machine

def svm(X, Y, c):
      m = len(X)
      P = matrix(         


        
相关标签:
3条回答
  • 2021-01-17 20:50

    i have try A=A.astype(double) to solve it, but it is invalid, since python doesn't know what double is or A has no method astype.

    therefore

    via using A = matrix(A, (1, m), 'd') could actually solve this problem!

    0 讨论(0)
  • 2021-01-17 21:02

    Your matrix elements have to be of the floating-point type as well. So the error is removed by using A = A.astype('float') to cast it.

    0 讨论(0)
  • 2021-01-17 21:09

    The error - "TypeError: 'A' must be a 'd' matrix with 1000 columns:" has two condition namely:

    1. if the type code is not equal to 'd'
    2. if the A.size[1] != c.size[0].

    Check for these conditions.

    0 讨论(0)
提交回复
热议问题