We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7cf94a9 + 479ec5e commit 4080094Copy full SHA for 4080094
comp_cos_sim_mat.py
@@ -10,7 +10,7 @@
10
embeddings.append(embedding)
11
embeddings = np.array(embeddings)
12
print(embeddings.T.shape)
13
-product = np.dot(embeddings, embeddings.T)
14
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)
+embeddings = np.asarray(embeddings / norm, "float32")
+product = np.dot(embeddings, embeddings.T)
+np.save(('cos_sim_counter_fitting.npy'), product)
0 commit comments