Skip to content

Commit

Permalink
calculate train set distances to the reference embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Nguyen-Vu committed Dec 7, 2023
1 parent bd3ecf7 commit 7f0ff30
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions oc_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def create_reference_embedding2(model, dataloader, device):
for emb in total_embeddings:
distance = F.pairwise_distance(reference_embedding, emb, p=2)
total_distances.append(distance)
with open("distances.txt", "a") as f:
f.write(f"{float(distance)}\n")
threshold = torch.max(torch.stack(total_distances))

# save the reference embedding and threshold to a file
Expand Down

0 comments on commit 7f0ff30

Please sign in to comment.