mirror of https://github.com/davisking/dlib.git
Added more comments about sparse vectors to the python examples
This commit is contained in:
parent
0660dc02e5
commit
1dd9888bae
|
@ -49,7 +49,10 @@ def sentence_to_vectors(sentence):
|
|||
# than the above form when you have very high dimensional vectors that are mostly full of
|
||||
# zeros. In dlib, each sparse vector is represented as an array of pair objects. Each
|
||||
# pair contains an index and value. Any index not listed in the vector is implicitly
|
||||
# associated with a value of zero.
|
||||
# associated with a value of zero. Additionally, when using sparse vectors with
|
||||
# dlib.train_sequence_segmenter() you can use "unsorted" sparse vectors. This means you
|
||||
# can add the index/value pairs into your sparse vectors in any order you want and don't
|
||||
# need to worry about them being in sorted order.
|
||||
def sentence_to_sparse_vectors(sentence):
|
||||
vects = dlib.sparse_vectors()
|
||||
has_cap = dlib.sparse_vector()
|
||||
|
|
|
@ -204,7 +204,11 @@ class three_class_classifier_problem:
|
|||
# problem. So you need to pick a PSI that doesn't make the label maximization step
|
||||
# intractable but also still well models your problem.
|
||||
|
||||
# Create a dense vector object.
|
||||
# Create a dense vector object (note that you can also use unsorted sparse vectors
|
||||
# (i.e. dlib.sparse_vector objects) to represent your PSI vector. This is useful
|
||||
# if you have very high dimensional PSI vectors that are mostly zeros. In the
|
||||
# context of this example, you would simply return a dlib.sparse_vector at the end
|
||||
# of make_psi() and the rest of the example would still work properly. ).
|
||||
psi = dlib.vector()
|
||||
# Set it to have 9 dimensions. Note that the elements of the vector are 0
|
||||
# initialized.
|
||||
|
|
Loading…
Reference in New Issue