Reputation: 12747
I'm using numpy 1.8.x and numba. I have a function called train
, which has the following definition:
@autojit
def train_function( X, y, H):
and it returns a 3D numpy array.
I then have a class, which calls this function, like so:
class GentleBoostC(object):
# different methods including init
# and now the train function
def train(self, X, y, H):
self.g_per_round = train_function(X,y,H)
I then instantiate the class and use it to train an object.
# initiate the variables X_train, y_train and boosting_rounds
gentlebooster = gbc.GentleBoostC() # gbc has already been imported
gentlebooster.train(X_train,y_train,boosting_rounds)
But then I get this error:
gentlebooster.train(X_train,y_train,boosting_rounds)
File "C:\Users\app\Documents\Python Scripts\gentleboost_c_class_jit_v7_nolimit.py", line 299, in train
self.g_per_round = train_function(self,X, y, H)
File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 152, in typeof_pyval
dtype = numpy_support.from_dtype(val.dtype)
File "C:\Anaconda\lib\site-packages\numba\numpy_support.py", line 61, in from_dtype
raise NotImplementedError(dtype)
NotImplementedError: object
What's going wrong here?
Looking at the documentation, it says:
exception NotImplementedError
This exception is derived from
RuntimeError
. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method.
How would this translate to my case?
More details on how I'm calling the train function:
#img_hogs and sample_labels have already been populated above, both are numpy arrays
X_train = np.array(img_hogs)
y_train = np.array(sample_labels)
boosting_rounds = 7
gentlebooster = gbc.GentleBoostC()
gentlebooster.train(X_train,y_train,boosting_rounds)
Upvotes: 1
Views: 3337
Reputation: 12747
My array X_train
was a numpy array of objects, and numba does not support that.
@Korem was right!
I was actually loading the img_hogs
variable from a file like this:
img_hogs = np.array(pickle.load(file("C:\\PATH_TO_FILE")), dtype=object)
I just kept overlooking that. When I finally just removed the dtype=object bit, it worked!
Upvotes: 1