You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the code and docstring of the cosine_distance_to_prototypes() method:
defcosine_distance_to_prototypes(self, samples) ->Tensor:
""" Compute prediction logits from their cosine distance to support set prototypes. Args: samples: features of the items to classify of shape (n_samples, feature_dimension) Returns: prediction logits of shape (n_samples, n_classes) """return (
nn.functional.normalize(samples, dim=1)
@ nn.functional.normalize(self.prototypes, dim=1).T
)
The method actually doesn't return cosine distances but predictions logits equal to the cosine similarity, so the higher is actually the better.
Same logic with the other available "distance", which is actually logits as the opposite of the distance:
defl2_distance_to_prototypes(self, samples: Tensor) ->Tensor:
""" Compute prediction logits from their euclidean distance to support set prototypes. Args: samples: features of the items to classify of shape (n_samples, feature_dimension) Returns: prediction logits of shape (n_samples, n_classes) """return-torch.cdist(samples, self.prototypes)
Calling the methods cosine_distance_to_prototypes() and l2_distance_to_prototypes() is a misleading naming. I am marking this as a much needed enhancement to the library.
If the model is returning cosine distance:
easy-few-shot-learning/easyfsl/methods/simple_shot.py
Line 29 in 8422b97
Does that mean the lower the better?
The text was updated successfully, but these errors were encountered: