我有以下类定义:
class GentleBoostC(object):
def __init__(self):
# do init stuff
# add jit in order to speed up the code
@jit
@void (float_[:,:],int_[:],int_)
def train(self, X, y, H):
# train do stuff
然后,在另一个文件中,我这样做:
import GentleBoostC as gbc
# initialize the 2D array X_train, the 1D array y_train, and the integer boosting_rounds
gentlebooster = gbc.GentleBoostC()
gentlebooster.train(X_train,y_train,boosting_rounds)
但后来我得到这个错误:
Traceback (most recent call last):
File "C:\Users\app\Documents\Python Scripts\gbc_classifier_train.py", line 53, in <module>
gentlebooster.train(X_train,y_train,boosting_rounds)
TypeError: _jit_decorator() takes exactly 1 argument (4 given)
我发现装饰器很混乱,直到这个错误我才意识到实现也jit
使用了装饰器!或者至少我猜是这样。