Skip to content

Commit

Permalink
bug fix for synModify array out of bound
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishiihara committed Aug 14, 2014
1 parent 083aa66 commit cad2011
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ class Word2Vec extends Serializable with Logging {
// Hierarchical softmax
var d = 0
while (d < bcVocab.value(word).codeLen) {
val ind = bcVocab.value(word).point(d)
val l2 = ind * vectorSize
val inner = bcVocab.value(word).point(d)
val l2 = inner * vectorSize
// Propagate hidden -> output
var f = blas.sdot(vectorSize, syn, l1, 1, syn, l2, 1)
if (f > -MAX_EXP && f < MAX_EXP) {
Expand All @@ -331,7 +331,7 @@ class Word2Vec extends Serializable with Logging {
val g = ((1 - bcVocab.value(word).code(d) - f) * alpha).toFloat
blas.saxpy(vectorSize, g, syn, l2, 1, neu1e, 0, 1)
blas.saxpy(vectorSize, g, syn, l1, 1, syn, l2, 1)
synModify(ind) += 1
synModify(inner) += 1
}
d += 1
}
Expand Down

0 comments on commit cad2011

Please sign in to comment.