Skip to content

Commit 4080094

Browse files
authored
Merge pull request #4 from leix28/master
reduce memory consumption.
2 parents 7cf94a9 + 479ec5e commit 4080094

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

comp_cos_sim_mat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
embeddings.append(embedding)
1111
embeddings = np.array(embeddings)
1212
print(embeddings.T.shape)
13-
product = np.dot(embeddings, embeddings.T)
1413
norm = np.linalg.norm(embeddings, axis=1, keepdims=True)
15-
cos_sim = product / np.dot(norm, norm.T)
16-
np.save(('cos_sim_counter_fitting.npy'), cos_sim)
14+
embeddings = np.asarray(embeddings / norm, "float32")
15+
product = np.dot(embeddings, embeddings.T)
16+
np.save(('cos_sim_counter_fitting.npy'), product)

0 commit comments

Comments
 (0)