Merge pull request #106 from chrislee973/fix-norm-calculation
Fix tensor normalization in EmbeddingsPipeline
This commit is contained in:
commit
13b570ce97
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue