mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 17:54:39 +03:00
8661218fe8
* Work on refactoring greedy parser * Compile updated parser * Fix refactored parser * Update test * Fix refactored parser * Fix refactored parser * Readd beam search after refactor * Fix beam search after refactor * Fix parser * Fix beam parsing * Support oracle segmentation in ud-train CLI command * Avoid relying on final gold check in beam search * Add a keyword argument sink to GoldParse * Bug fixes to beam search after refactor * Avoid importing fused token symbol in ud-run-test, untl that's added * Avoid importing fused token symbol in ud-run-test, untl that's added * Don't modify Token in global scope * Fix error in beam gradient calculation * Default to beam_update_prob 1 * Set a more aggressive threshold on the max violn update * Disable some tests to figure out why CI fails * Disable some tests to figure out why CI fails * Add some diagnostics to travis.yml to try to figure out why build fails * Tell Thinc to link against system blas on Travis * Point thinc to libblas on Travis * Try running sudo=true for travis * Unhack travis.sh * Restore beam_density argument for parser beam * Require thinc 6.11.1.dev16 * Revert hacks to tests * Revert hacks to travis.yml * Update thinc requirement * Fix parser model loading * Fix size limits in training data * Add missing name attribute for parser * Fix appveyor for Windows
50 lines
1.1 KiB
Cython
50 lines
1.1 KiB
Cython
from libc.string cimport memset, memcpy
|
|
from libc.stdlib cimport calloc, free, realloc
|
|
from thinc.typedefs cimport weight_t, class_t, hash_t
|
|
|
|
from ._state cimport StateC
|
|
|
|
|
|
cdef struct SizesC:
|
|
int states
|
|
int classes
|
|
int hiddens
|
|
int pieces
|
|
int feats
|
|
int embed_width
|
|
|
|
|
|
cdef struct WeightsC:
|
|
const float* feat_weights
|
|
const float* feat_bias
|
|
const float* hidden_bias
|
|
const float* hidden_weights
|
|
const float* vectors
|
|
|
|
|
|
cdef struct ActivationsC:
|
|
int* token_ids
|
|
float* vectors
|
|
float* unmaxed
|
|
float* scores
|
|
float* hiddens
|
|
int* is_valid
|
|
int _curr_size
|
|
int _max_size
|
|
|
|
|
|
cdef WeightsC get_c_weights(model) except *
|
|
|
|
cdef SizesC get_c_sizes(model, int batch_size) except *
|
|
|
|
cdef void resize_activations(ActivationsC* A, SizesC n) nogil
|
|
|
|
cdef void predict_states(ActivationsC* A, StateC** states,
|
|
const WeightsC* W, SizesC n) nogil
|
|
|
|
cdef int arg_max_if_valid(const weight_t* scores, const int* is_valid, int n) nogil
|
|
|
|
cdef void cpu_log_loss(float* d_scores,
|
|
const float* costs, const int* is_valid, const float* scores, int O) nogil
|
|
|