我无法运行此代码。当我运行它时,它给了我一个错误,根据我的理解,它意味着它无法导入cvxopt.base模块。 如果有人遇到此错误或知道此问题的解决方案,请联系。
我正在分享代码&以下Python界面的痕迹:
守则:
#!/usr/bin/env python
import numpy as np
from numpy import linalg
from cvxopt import solvers
def Twin_plane_1(R,S,C1,Epsi1,regulz1):
StS = np.dot(S.T,S)
# for regularization we add identity matrix with wt. before inversion
StS = StS + regulz1*(np.identity(StS.shape[0]))
StSRt = linalg.solve(StS,R.T)
RtStSRt = np.dot(R,StSRt)
RtStSRt = (RtStSRt+(RtStSRt.T))/2
m2 = R.shape[0]
e2 = -np.ones((m2,1))
solvers.options['show_progress'] = False
vlb = np.zeros((m2,1))
vub = C1*(np.ones((m2,1)))
# x<=vub
# x>=vlb -> -x<=-vlb
# cdx<=vcd
cd = np.vstack((np.identity(m2),-np.identity(m2)))
vcd = np.vstack((vub,-vlb))
alpha = solvers.qp(matrix(RtStSRt,tc='d'),matrix(e2,tc='d'),matrix(cd,tc='d'),matrix(vcd,tc='d'))#,matrix(0.0,(1,m1)),matrix(0.0))#,None,matrix(x0))
alphasol = np.array(alpha['x'])
z = -np.dot(StSRt,alphasol)
w1 = z[:len(z)-1]
b1 = z[len(z)-1]
return [w1,b1]
追踪:
Traceback(最近一次调用最后一次):文件 “C:\ Users \用户秀\下载\双SVM-主\双SVM-主\ TwinPlane1.py”, 第6行,在 来自cvxopt导入解算器文件“C:\ Python35 \ lib \ site-packages \ cvxopt__init __。py”,第50行,in import cvxopt.base ImportError:DLL加载失败:找不到指定的模块。
答案 0 :(得分:0)
我遇到了同样的问题......试试这个:
import os
os.environ['PATH'] += r';C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\Library\\mingw-
w64\\bin'