mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-15 22:27:12 +03:00
37 lines
1.2 KiB
Cython
37 lines
1.2 KiB
Cython
from thinc.linear.features cimport ConjunctionExtracter
|
|
from thinc.typedefs cimport atom_t, weight_t
|
|
from thinc.structs cimport FeatureC
|
|
from libc.stdint cimport uint32_t, uint64_t
|
|
cimport numpy as np
|
|
from cymem.cymem cimport Pool
|
|
from libcpp.vector cimport vector
|
|
|
|
|
|
cdef class LinearModel:
|
|
cdef ConjunctionExtracter extracter
|
|
cdef readonly int nr_class
|
|
cdef readonly uint32_t nr_weight
|
|
cdef public weight_t learn_rate
|
|
cdef public weight_t momentum
|
|
cdef Pool mem
|
|
cdef weight_t time
|
|
cdef weight_t* W
|
|
cdef weight_t* mom
|
|
cdef weight_t* averages
|
|
cdef weight_t* last_upd
|
|
|
|
cdef void hinge_lossC(self, weight_t* d_scores,
|
|
const weight_t* scores, const weight_t* costs) nogil
|
|
|
|
cdef void log_lossC(self, weight_t* d_scores,
|
|
const weight_t* scores, const weight_t* costs) nogil
|
|
|
|
cdef void regression_lossC(self, weight_t* d_scores,
|
|
const weight_t* scores, const weight_t* costs) nogil
|
|
|
|
cdef void set_scoresC(self, weight_t* scores,
|
|
const FeatureC* features, int nr_feat) nogil
|
|
|
|
cdef void set_gradientC(self, const weight_t* d_scores, const FeatureC*
|
|
features, int nr_feat) nogil
|