ppbrown commited on
Commit
075cee0
1 Parent(s): bac0dfe

actual generate distance grid now

Browse files
Files changed (1) hide show
  1. generate-distances.py +14 -1
generate-distances.py CHANGED
@@ -28,10 +28,23 @@ print("read in embeddingsnow",file=sys.stderr)
28
  model = safe_open(embed_file,framework="pt",device="cuda")
29
  embs=model.get_tensor("embeddings")
30
 
 
31
 
32
- print("Shape of result = ",embs.shape)
 
33
 
34
 
35
  print("calculate distances now")
36
 
 
 
37
 
 
 
 
 
 
 
 
 
 
 
28
  model = safe_open(embed_file,framework="pt",device="cuda")
29
  embs=model.get_tensor("embeddings")
30
 
31
+ embs.to(device)
32
 
33
+
34
+ print("Shape of loaded embeds =",embs.shape)
35
 
36
 
37
  print("calculate distances now")
38
 
39
+ distances = torch.cdist(embs, embs, p=2)
40
+ print("distances shape is",distances.shape)
41
 
42
+ """
43
+ import torch.nn.functional as F
44
+ pos=0
45
+ for word in tokendict.keys():
46
+ print("Calculating distances from",word)
47
+ home=embs[pos]
48
+ #distances = torch.cdist(embs, home.unsqueeze(0), p=2)
49
+ #distance = F.pairwise_distance(home, embs[,p=2).item()
50
+ """