I am having trouble using Numba to solve least squares in python. This is the code I have:
import numpy as np
from numba import jit
@jit(nopython=True)
def test(A, B):
alpha = np.linalg.lstsq(A,B,rcond=None)
return alpha
A = np.random.rand(10,3)
B = np.random.rand(10,1)
alpha = test(A,B)
print(alpha)
Without the line "@jit(nopython=True)" it works. With the "@jit" I have the following error:
Invalid use of Function(<function lstsq at 0x000001767E21E318>) with argument(s) of type(s): (array(float64, 2d, C), array(float64, 2d, C), rcond=none)
* parameterized
In definition 0:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of ExternalFunction(numba_ez_gelsd) with argument(s) of type(s): (Literal[int](100), int64, int64, int64, ArrayCTypes(dtype=float64, ndim=2), int64, ArrayCT
ypes(dtype=float64, ndim=2), int64, ArrayCTypes(dtype=float64, ndim=1), none, ArrayCTypes(dtype=int32, ndim=1))
Known signatures:
* (int8, int64, int64, int64, float64*, int64, float64*, int64, float64*, float64, int32*) -> int32
In definition 0:
All templates rejected with literals.
In definition 1:
All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: ExternalFunction(numba_ez_gelsd)
[2] During: typing of call at C:\Users\owner\anaconda3\lib\site-packages\numba\targets\linalg.py (1645)
Any suggestions?
删除rcond=None关键字,它会正常工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.