Skip to content

Commit d0e93c0

Browse files
committed
add initial value for reduce
1 parent c067e2a commit d0e93c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pipelines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class EmbeddingsPipeline extends Pipeline {
628628
*/
629629
_normalize(tensor) {
630630
for (let batch of tensor) {
631-
let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b))
631+
let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b, 0))
632632

633633
for (let i = 0; i < batch.data.length; ++i) {
634634
batch.data[i] /= norm;

0 commit comments

Comments
 (0)