SparseLinear model weight index access from pointer variable #11379
-
Hi, Just a doubt that index is correctly accessed in the weights pointer variable?
nO = Output dimension, determined by the number of different labels. Let's assume it to be 5 categories. (nO=5) length = 218 = 262144** SparseLinear model has two learnable params W(weight) of shape (nO*length) and b(bias) of shape (nO) W = 5*262114 (Assuming each row of 262114 represents learnable vector for each class)
On highlevel, (let's assume output of extract_ngrams will be passed to SparseLinear model) scores = array of length (batch_size,5) (output matrix)
idx1 and idx2 will not exceed the value 262114.
By conceptually understanding, for each class we need to do operation weights[idx1,clas]*value and weights[idx2,clas]*value (numpy operation in 2d matrix)
weight allocation:
W is pointed to pointer variable weights in set_scoresC fucntion. So value from pointer operation by accessing the index We should be using multiplication instead of addition in the below statements,
because idx1 and idx2 will not be greater than 262114 and weight initialized with size (5*262114), but output of (idx1+clas) and (idx1+clas) will not be greater than (262115+5). Weights in indexes greater (262115+5) will be never be used in the process. Please correct me if my interpretation is not correct. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for reporting this! I agree that the indexing is wrong. I have created an issue for this: |
Beta Was this translation helpful? Give feedback.
Thanks for reporting this! I agree that the indexing is wrong. I have created an issue for this:
explosion/thinc#752