Upload compare-allids-embeds.py
Browse files- compare-allids-embeds.py +19 -2
compare-allids-embeds.py
CHANGED
|
@@ -50,7 +50,24 @@ print(f"calculating distances...")
|
|
| 50 |
|
| 51 |
targetdistances = torch.norm(embs2 - embs1, dim=1)
|
| 52 |
print(targetdistances.shape)
|
| 53 |
-
tl=targetdistances.tolist()
|
|
|
|
| 54 |
|
| 55 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
|
|
|
| 50 |
|
| 51 |
targetdistances = torch.norm(embs2 - embs1, dim=1)
|
| 52 |
print(targetdistances.shape)
|
| 53 |
+
#tl=targetdistances.tolist()
|
| 54 |
+
#print(tl[:10])
|
| 55 |
|
| 56 |
+
print("sum of distances=",torch.sum(targetdistances))
|
| 57 |
+
|
| 58 |
+
import PyQt5
|
| 59 |
+
import matplotlib
|
| 60 |
+
matplotlib.use('QT5Agg') # Set the backend to QT5Agg
|
| 61 |
+
|
| 62 |
+
import matplotlib.pyplot as plt
|
| 63 |
+
|
| 64 |
+
junk, ax = plt.subplots()
|
| 65 |
+
graph1=targetdistances.tolist()
|
| 66 |
+
ax.plot(graph1, label="Distance between same tokenID")
|
| 67 |
+
ax.set_title("Comparison between two CLIPTextModel datasets")
|
| 68 |
+
ax.set_ylabel("Distance")
|
| 69 |
+
ax.set_xlabel("CLIP TokenID")
|
| 70 |
+
|
| 71 |
+
ax.legend()
|
| 72 |
+
plt.show()
|
| 73 |
|