mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 09:44:36 +03:00
move new function out of class
This commit is contained in:
parent
2531ed9575
commit
afaf41f794
|
@ -227,16 +227,16 @@ cdef int arg_max_if_valid(const weight_t* scores, const int* is_valid, int n) no
|
||||||
best = i
|
best = i
|
||||||
return best
|
return best
|
||||||
|
|
||||||
cdef inline int _arg_max(float[:] scores, const int n_classes) nogil:
|
cdef int _arg_max(const float* scores, const int n_classes) nogil:
|
||||||
if n_classes == 2:
|
|
||||||
return 0 if scores[0] > scores[1] else 1
|
|
||||||
cdef int i
|
cdef int i
|
||||||
cdef int best = 0
|
cdef int best = 0
|
||||||
cdef float mode = scores[0]
|
cdef float mode = scores[0]
|
||||||
|
|
||||||
for i in range(1, n_classes):
|
for i in range(1, n_classes):
|
||||||
if scores[i] > mode:
|
if scores[i] > mode:
|
||||||
mode = scores[i]
|
mode = scores[i]
|
||||||
best = i
|
best = i
|
||||||
|
|
||||||
return best
|
return best
|
||||||
|
|
||||||
class ParserStepModel(Model):
|
class ParserStepModel(Model):
|
||||||
|
@ -538,5 +538,3 @@ cdef class precompute_hiddens:
|
||||||
|
|
||||||
return state_vector, backprop_relu
|
return state_vector, backprop_relu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user