1

我正在通过我的fmin这种方式:

position, value, dictionary =fmin_l_bfgs_b(func =self.objective,x0=wcb,fprime = self.objective_grad,args=(X,y),disp = 10)

这看起来很标准:objective 返回一个标量,objective gradient 返回一个ndarraysize 2n+1

我收到以下错误:

<ipython-input-35-6a424a7ec22a> in fit(self, X, y)
     35         wcb = np.asarray(wcb)
     36         print(wcb)
---> 37         position, value, dictionary =fmin_l_bfgs_b(func =self.objective,x0=wcb,fprime = self.objective_grad,args=(X,y),disp = 10)
     38 
     39 

~\Anaconda3\envs\smc\lib\site-packages\scipy\optimize\lbfgsb.py in fmin_l_bfgs_b(func, x0, fprime, args, approx_grad, bounds, m, factr, pgtol, epsilon, iprint, maxfun, maxiter, disp, callback, maxls)
    197 
    198     res = _minimize_lbfgsb(fun, x0, args=args, jac=jac, bounds=bounds,
--> 199                            **opts)
    200     d = {'grad': res['jac'],
    201          'task': res['message'],

~\Anaconda3\envs\smc\lib\site-packages\scipy\optimize\lbfgsb.py in _minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, maxfun, maxiter, iprint, callback, maxls, **unknown_options)
    326         _lbfgsb.setulb(m, x, low_bnd, upper_bnd, nbd, f, g, factr,
    327                        pgtol, wa, iwa, task, iprint, csave, lsave,
--> 328                        isave, dsave, maxls)
    329         task_str = task.tostring()
    330         if task_str.startswith(b'FG'):
ValueError: failed to initialize intent(inout) array -- input 'O' not compatible to 'd'

知道如何摆脱它吗?

4

0 回答 0