mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-05 14:10:34 +03:00
remove backend as per #13701
This commit is contained in:
parent
3e30b5bef6
commit
e3eac03d40
|
@ -5,7 +5,6 @@ from libc.math cimport exp
|
||||||
from libc.stdlib cimport calloc, free, realloc
|
from libc.stdlib cimport calloc, free, realloc
|
||||||
from libc.string cimport memcpy, memset
|
from libc.string cimport memcpy, memset
|
||||||
from thinc.backends.cblas cimport saxpy, sgemm
|
from thinc.backends.cblas cimport saxpy, sgemm
|
||||||
from thinc.backends.linalg cimport Vec, VecVec
|
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
import numpy.random
|
import numpy.random
|
||||||
|
@ -116,14 +115,10 @@ cdef void predict_states(
|
||||||
n.hiddens * n.pieces
|
n.hiddens * n.pieces
|
||||||
)
|
)
|
||||||
for i in range(n.states):
|
for i in range(n.states):
|
||||||
VecVec.add_i(
|
saxpy(cblas)(n.hiddens * n.pieces, 1., W.feat_bias, 1, &A.unmaxed[i*n.hiddens*n.pieces], 1)
|
||||||
&A.unmaxed[i*n.hiddens*n.pieces],
|
|
||||||
W.feat_bias, 1.,
|
|
||||||
n.hiddens * n.pieces
|
|
||||||
)
|
|
||||||
for j in range(n.hiddens):
|
for j in range(n.hiddens):
|
||||||
index = i * n.hiddens * n.pieces + j * n.pieces
|
index = i * n.hiddens * n.pieces + j * n.pieces
|
||||||
which = Vec.arg_max(&A.unmaxed[index], n.pieces)
|
which = _arg_max(&A.unmaxed[index], n.pieces)
|
||||||
A.hiddens[i*n.hiddens + j] = A.unmaxed[index + which]
|
A.hiddens[i*n.hiddens + j] = A.unmaxed[index + which]
|
||||||
memset(A.scores, 0, n.states * n.classes * sizeof(float))
|
memset(A.scores, 0, n.states * n.classes * sizeof(float))
|
||||||
if W.hidden_weights == NULL:
|
if W.hidden_weights == NULL:
|
||||||
|
@ -138,7 +133,7 @@ cdef void predict_states(
|
||||||
)
|
)
|
||||||
# Add bias
|
# Add bias
|
||||||
for i in range(n.states):
|
for i in range(n.states):
|
||||||
VecVec.add_i(&A.scores[i*n.classes], W.hidden_bias, 1., n.classes)
|
saxpy(cblas)(n.classes, 1., W.hidden_bias, 1, &scores[i*n.classes], 1)
|
||||||
# Set unseen classes to minimum value
|
# Set unseen classes to minimum value
|
||||||
i = 0
|
i = 0
|
||||||
min_ = A.scores[0]
|
min_ = A.scores[0]
|
||||||
|
@ -187,7 +182,7 @@ cdef void cpu_log_loss(
|
||||||
"""Do multi-label log loss"""
|
"""Do multi-label log loss"""
|
||||||
cdef double max_, gmax, Z, gZ
|
cdef double max_, gmax, Z, gZ
|
||||||
best = arg_max_if_gold(scores, costs, is_valid, O)
|
best = arg_max_if_gold(scores, costs, is_valid, O)
|
||||||
guess = Vec.arg_max(scores, O)
|
guess = _arg_max(scores, O)
|
||||||
if best == -1 or guess == -1:
|
if best == -1 or guess == -1:
|
||||||
# These shouldn't happen, but if they do, we want to make sure we don't
|
# These shouldn't happen, but if they do, we want to make sure we don't
|
||||||
# cause an OOB access.
|
# cause an OOB access.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user