From 6c0d4766aae0e7550821f003365a1c7d4f90002e Mon Sep 17 00:00:00 2001 From: Peter Kuhar Date: Thu, 26 Jan 2023 16:58:42 -0800 Subject: [PATCH] Fixed documentation for Zero-Shot Prediction norm must be done with dim=1 not dim=-1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e4feb996e..c5bf501b1 100644 --- a/README.md +++ b/README.md @@ -112,8 +112,8 @@ with torch.no_grad(): text_features = model.encode_text(text_inputs) # Pick the top 5 most similar labels for the image -image_features /= image_features.norm(dim=-1, keepdim=True) -text_features /= text_features.norm(dim=-1, keepdim=True) +image_features /= image_features.norm(dim=1, keepdim=True) +text_features /= text_features.norm(dim=1, keepdim=True) similarity = (100.0 * image_features @ text_features.T).softmax(dim=-1) values, indices = similarity[0].topk(5)