From d0e93c044beb1b817d5fa703a1543a1d6461d315 Mon Sep 17 00:00:00 2001 From: chrislee973 Date: Sat, 6 May 2023 21:39:18 -0700 Subject: [PATCH] add initial value for reduce --- src/pipelines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipelines.js b/src/pipelines.js index 8ca50c4b8..b90484b96 100644 --- a/src/pipelines.js +++ b/src/pipelines.js @@ -628,7 +628,7 @@ class EmbeddingsPipeline extends Pipeline { */ _normalize(tensor) { for (let batch of tensor) { - let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b)) + let norm = Math.sqrt(batch.data.reduce((a, b) => a + b * b, 0)) for (let i = 0; i < batch.data.length; ++i) { batch.data[i] /= norm;